import * as path from 'path'; import { workspace, ExtensionContext } from 'vscode'; import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, } from 'vscode-languageclient/node'; let client: LanguageClient; export function activate(context: ExtensionContext) { const serverModule = context.asAbsolutePath( path.join('out', 'server', 'src', 'server.js') ); const serverOptions: ServerOptions = { run: { module: serverModule, transport: TransportKind.ipc }, debug: { module: serverModule, transport: TransportKind.ipc, options: { execArgv: ['--nolazy', '--inspect=6009'] }, }, }; const clientOptions: LanguageClientOptions = { documentSelector: [{ scheme: 'file', language: 'html' }], synchronize: { configurationSection: 'nojs', fileEvents: workspace.createFileSystemWatcher('**/*.html'), }, }; client = new LanguageClient( 'nojsLanguageServer', 'No.JS Language Server', serverOptions, clientOptions ); client.start(); } export function deactivate(): Thenable | undefined { if (!client) { return undefined; } return client.stop(); }