Files
vscode-extension-samples/lsp-multi-server-sample/server/src/server.ts

36 lines
1.2 KiB
TypeScript
Raw Normal View History

/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
2017-08-23 16:40:19 +02:00
import {
createConnection, TextDocuments, ProposedFeatures, TextDocumentSyncKind
} from 'vscode-languageserver';
2017-08-23 16:40:19 +02:00
// Creates the LSP connection
let connection = createConnection(ProposedFeatures.all);
2018-02-20 11:01:40 +01:00
// Create a manager for open text documents
2017-08-23 16:40:19 +02:00
let documents = new TextDocuments();
// The workspace folder this server is operating on
let workspaceFolder: string | null;
2017-08-23 16:40:19 +02:00
documents.onDidOpen((event) => {
2017-10-31 10:34:06 +01:00
connection.console.log(`[Server(${process.pid}) ${workspaceFolder}] Document opened: ${event.document.uri}`);
})
2017-08-23 16:40:19 +02:00
documents.listen(connection);
connection.onInitialize((params) => {
workspaceFolder = params.rootUri;
2017-10-31 10:34:06 +01:00
connection.console.log(`[Server(${process.pid}) ${workspaceFolder}] Started and initialize received`);
2017-08-23 16:40:19 +02:00
return {
capabilities: {
textDocumentSync: {
openClose: true,
change: TextDocumentSyncKind.None
}
}
}
2017-08-23 16:40:19 +02:00
});
connection.listen();