Feat: first work for rsx vscode ext

This commit is contained in:
Jonathan Kelley committed 2021-01-26 14:02:35 -05:00
1 parent 65d0d611ea
commit 2e626aea51
27 files changed
+4701 -31

No files matched your search

+48
View File
@@ -0,0 +1,48 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
import { getLanguageService } from 'vscode-html-languageservice';
import { createConnection, InitializeParams, ProposedFeatures, TextDocuments, TextDocumentSyncKind } from 'vscode-languageserver';
import { TextDocument } from 'vscode-languageserver-textdocument';
// Create a connection for the server. The connection uses Node's IPC as a transport.
// Also include all preview / proposed LSP features.
let connection = createConnection(ProposedFeatures.all);
// Create a simple text document manager. The text document manager
// supports full document sync only
let documents: TextDocuments<TextDocument> = new TextDocuments(TextDocument);
const htmlLanguageService = getLanguageService();
connection.onInitialize((_params: InitializeParams) => {
return {
capabilities: {
textDocumentSync: TextDocumentSyncKind.Full,
// Tell the client that the server supports code completion
completionProvider: {
resolveProvider: false
}
}
};
});
connection.onInitialized(() => { });
connection.onCompletion(async (textDocumentPosition, token) => {
const document = documents.get(textDocumentPosition.textDocument.uri);
if (!document) {
return null;
}
return htmlLanguageService.doComplete(
document,
textDocumentPosition.position,
htmlLanguageService.parseHTMLDocument(document)
);
});
documents.listen(connection);
connection.listen();