33 lines
1,022 B
TypeScript
33 lines
1,022 B
TypeScript
|
import { getLanguageService } from 'vscode-html-languageservice';
|
||
|
import { createConnection, ProposedFeatures, TextDocuments, TextDocumentSyncKind } from 'vscode-languageserver';
|
||
|
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||
|
|
||
|
let connection = createConnection(ProposedFeatures.all);
|
||
|
let documents: TextDocuments<TextDocument> = new TextDocuments(TextDocument);
|
||
|
|
||
|
const htmlLanguageService = getLanguageService();
|
||
|
|
||
|
connection.onInitialize(() => {
|
||
|
return {
|
||
|
capabilities: {
|
||
|
textDocumentSync: TextDocumentSyncKind.Full,
|
||
|
completionProvider: {
|
||
|
resolveProvider: false,
|
||
|
},
|
||
|
},
|
||
|
};
|
||
|
});
|
||
|
|
||
|
connection.onCompletion(async (textDocumentPosition, token) => {
|
||
|
console.log(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();
|