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

41 lines
1.4 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
2021-01-15 09:16:50 +01:00
} from 'vscode-languageserver/node';
import {
TextDocument
} from 'vscode-languageserver-textdocument';
2017-08-23 16:40:19 +02:00
// Creates the LSP connection
2020-06-11 17:41:06 +02:00
const connection = createConnection(ProposedFeatures.all);
2018-02-20 11:01:40 +01:00
// Create a manager for open text documents
2021-08-05 14:21:54 +02:00
const documents: TextDocuments<TextDocument> = new TextDocuments(TextDocument);
// 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}`);
2019-08-16 10:07:30 +02:00
});
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
}
}
2019-08-16 10:07:30 +02:00
};
2017-08-23 16:40:19 +02:00
});
connection.listen();