mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-06-13 07:10:26 +08:00
31 lines
885 B
TypeScript
31 lines
885 B
TypeScript
|
|
/*---------------------------------------------------------
|
||
|
|
* Copyright (C) Microsoft Corporation. All rights reserved.
|
||
|
|
*--------------------------------------------------------*/
|
||
|
|
'use strict';
|
||
|
|
|
||
|
|
import {
|
||
|
|
createConnection, TextDocuments, ProposedProtocol, TextDocumentSyncKind
|
||
|
|
} from 'vscode-languageserver';
|
||
|
|
|
||
|
|
let connection = createConnection(ProposedProtocol);
|
||
|
|
let documents = new TextDocuments();
|
||
|
|
let rootUri: string;
|
||
|
|
|
||
|
|
documents.onDidOpen((event) => {
|
||
|
|
connection.console.log(`[Server ${rootUri}] Document opened: ${event.document.uri}`);
|
||
|
|
})
|
||
|
|
documents.listen(connection);
|
||
|
|
|
||
|
|
connection.onInitialize((params) => {
|
||
|
|
rootUri = params.rootUri;
|
||
|
|
connection.console.log(`Server started for folder: ${rootUri}`);
|
||
|
|
return {
|
||
|
|
capabilities: {
|
||
|
|
textDocumentSync: {
|
||
|
|
openClose: true,
|
||
|
|
change: TextDocumentSyncKind.None
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
connection.listen();
|