Add lsp code action ui sample

This commit is contained in:
Dirk Baeumer
2019-11-15 19:19:44 +01:00
parent 92354b3a8a
commit 3fa2d68290
23 changed files with 5487 additions and 0 deletions

View File

@ -0,0 +1,5 @@
{
"extends": "../.eslintrc.base.json",
"rules": {
}
}

View File

@ -0,0 +1,47 @@
{
"name": "client",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@types/vscode": {
"version": "1.38.0",
"resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.38.0.tgz",
"integrity": "sha512-aGo8LQ4J1YF0T9ORuCO+bhQ5sGR1MXa7VOyOdEP685se3wyQWYUExcdiDi6rvaK61KUwfzzA19JRLDrUbDl7BQ==",
"dev": true
},
"semver": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw=="
},
"vscode-jsonrpc": {
"version": "5.0.0-next.4",
"resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-5.0.0-next.4.tgz",
"integrity": "sha512-Tos3tXP62ZTB9WowWwhvfVNdu1mEwQF/j7DqJuVL4QKhk311gH+mda0PZpG95LWyh5CCRpHMns4vNmMgZQrvXQ=="
},
"vscode-languageclient": {
"version": "6.0.0-next.6",
"resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-6.0.0-next.6.tgz",
"integrity": "sha512-Fd9dkQSgjVaSRXDFEMj4rGJEcTJ3sOzxb71wP2U91JJYr46rWxFLoxtZIfm7ABeajal69YUpo+5gHLLb5CCf9g==",
"requires": {
"semver": "^6.3.0",
"vscode-languageserver-protocol": "^3.15.0-next.11"
}
},
"vscode-languageserver-protocol": {
"version": "3.15.0-next.11",
"resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.15.0-next.11.tgz",
"integrity": "sha512-tpRnPtyS6q0EYH5RH12AtdMecgu3HVL2bBdBGzeQRN8Tf93I9LY4Fl5TXUNkIBjuxjMshkCM8ikhb+hlnWvB2w==",
"requires": {
"vscode-jsonrpc": "^5.0.0-next.3",
"vscode-languageserver-types": "^3.15.0-next.7"
}
},
"vscode-languageserver-types": {
"version": "3.15.0-next.8",
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.15.0-next.8.tgz",
"integrity": "sha512-AEfWrSNyeamWMKPehh/kd3nBnKD9ZGCPhzfxMnW9YNqElSh28G2+Puk3knIQWyaWyV6Bzh28ok9BRJsPzXFCkQ=="
}
}
}

View File

@ -0,0 +1,24 @@
{
"name": "client",
"displayName": "Code Action UI Sample - Client",
"version": "1.0.0",
"private": true,
"author": "Microsoft Corporation",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/Microsoft/vscode-extension-samples.git"
},
"bugs": {
"url": "https://github.com/Microsoft/vscode-extension-samples/issues"
},
"engines": {
"vscode": "^1.38.0"
},
"devDependencies": {
"@types/vscode": "1.38.0"
},
"dependencies": {
"vscode-languageclient": "6.0.0-next.6"
}
}

View File

@ -0,0 +1,51 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
import * as path from 'path';
import { ExtensionContext, window as Window } from 'vscode';
import { LanguageClient, LanguageClientOptions, RevealOutputChannelOn, ServerOptions, TransportKind } from 'vscode-languageclient';
export function activate(context: ExtensionContext): void {
const serverModule = context.asAbsolutePath(path.join('server', 'out', 'sampleServer.js'));
let serverOptions: ServerOptions = {
run: { module: serverModule, transport: TransportKind.ipc, options: { cwd: process.cwd() } },
debug: { module: serverModule, transport: TransportKind.ipc, options: { execArgv: ['--nolazy', '--inspect=6011'], cwd: process.cwd() } }
};
let clientOptions: LanguageClientOptions = {
documentSelector: [{ scheme: 'file', language: 'plaintext' }],
diagnosticCollectionName: 'sample',
revealOutputChannelOn: RevealOutputChannelOn.Never,
progressOnInitialization: true,
middleware: {
executeCommand: async (command, args, next) => {
const selected = await Window.showQuickPick(['Visual Studio', 'Visual Studio Code']);
if (selected === undefined) {
return next(command, args);
}
args = args.slice(0);
args.push(selected);
return next(command, args);
}
}
};
let client: LanguageClient;
try {
client = new LanguageClient('UI Sample', serverOptions, clientOptions);
} catch (err) {
Window.showErrorMessage(`The extension couldn't be started. See the output channel for details.`);
return;
}
client.registerProposedFeatures();
context.subscriptions.push(
client.start(),
);
}
export function deactivate() {
}

View File

@ -0,0 +1,17 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"target": "es2017",
"outDir": "out",
"rootDir": "src",
"lib": [ "es2017" ],
"sourceMap": true
},
"include": [
"src"
],
"exclude": [
"node_modules"
]
}

View File

@ -0,0 +1,22 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
//@ts-check
'use strict';
const withDefaults = require('../shared.webpack.config');
const path = require('path');
module.exports = withDefaults({
context: path.join(__dirname),
entry: {
extension: './src/extension.ts',
},
output: {
filename: 'extension.js',
path: path.join(__dirname, 'out')
}
});