mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-06-13 07:10:26 +08:00
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
/*---------------------------------------------------------
|
|
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
*--------------------------------------------------------*/
|
|
'use strict';
|
|
|
|
import {
|
|
createConnection, TextDocuments, ProposedFeatures, TextDocumentSyncKind
|
|
} from 'vscode-languageserver';
|
|
|
|
// Creates the LSP connection
|
|
let connection = createConnection(ProposedFeatures.all);
|
|
// Create a manager for open text documents
|
|
|
|
let documents = new TextDocuments();
|
|
|
|
// The workspace folder this server is operating on
|
|
let workspaceFolder: string;
|
|
|
|
documents.onDidOpen((event) => {
|
|
connection.console.log(`[Server(${process.pid}) ${workspaceFolder ? workspaceFolder : 'generic'}] Document opened: ${event.document.uri}`);
|
|
})
|
|
documents.listen(connection);
|
|
|
|
connection.onInitialize((params) => {
|
|
if (params.initializationOptions && params.initializationOptions.genericServer) {
|
|
connection.console.log(`[Server(${process.pid}) generic] Started and initialize received`);
|
|
} else {
|
|
workspaceFolder = params.rootUri;
|
|
connection.console.log(`[Server(${process.pid}) ${workspaceFolder}] Started and initialize received`);
|
|
}
|
|
return {
|
|
capabilities: {
|
|
textDocumentSync: {
|
|
openClose: true,
|
|
change: TextDocumentSyncKind.None
|
|
}
|
|
}
|
|
}
|
|
});
|
|
connection.listen(); |