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,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() {
}