mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 09:38:38 +01:00
Adopt LS service/client that has common & node
This commit is contained in:
@@ -4,10 +4,35 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { getNodeFSRequestService } from './nodeFs';
|
||||
import { ExtensionContext } from 'vscode';
|
||||
import { startClient } from '../cssClient';
|
||||
import { ExtensionContext, extensions } from 'vscode';
|
||||
import { startClient, LanguageClientConstructor } from '../cssClient';
|
||||
|
||||
import { ServerOptions, TransportKind, LanguageClientOptions, LanguageClient } from 'vscode-languageclient/node';
|
||||
|
||||
// this method is called when vs code is activated
|
||||
export function activate(context: ExtensionContext) {
|
||||
startClient(context, { fs: getNodeFSRequestService() });
|
||||
|
||||
const clientMain = extensions.getExtension('vscode.css-language-features')?.packageJSON?.main;
|
||||
const serverMain = clientMain?.replace('client', 'server').replace('cssClientMain', 'cssServerMain');
|
||||
if (!serverMain) {
|
||||
throw new Error('Unable to compute CSS server module path. Client: ' + clientMain);
|
||||
}
|
||||
|
||||
const serverModule = context.asAbsolutePath(serverMain);
|
||||
|
||||
// The debug options for the server
|
||||
const debugOptions = { execArgv: ['--nolazy', '--inspect=6044'] };
|
||||
|
||||
// If the extension is launch in debug mode the debug server options are use
|
||||
// Otherwise the run options are used
|
||||
const serverOptions: ServerOptions = {
|
||||
run: { module: serverModule, transport: TransportKind.ipc },
|
||||
debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions }
|
||||
};
|
||||
|
||||
const newLanguageClient: LanguageClientConstructor = (id: string, name: string, clientOptions: LanguageClientOptions) => {
|
||||
return new LanguageClient(id, name, serverOptions, clientOptions);
|
||||
};
|
||||
|
||||
startClient(context, newLanguageClient, { fs: getNodeFSRequestService() });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user