我有一个用例,其中有一种语言X,其中支持HTML。因为,我在VScode中将文件扩展名关联为'.x',所以在X内我的HTML并没有获得自动完成和属性建议。
我尝试过的方法,
vscode.html
并通过activate方法将其激活。const htmlPluginId = 'vscode.html';
export const activate = () => {
const htmlPlugin = vscode.extensions.getExtension(htmlPluginId);
const ht = await htmlPlugin.activate();
}
这不起作用。我想HTML插件无法与语言X关联。
vscode-html-languageserver
中已经存在的内容。import {getLanguageService} from 'vscode-html-languageservice';
let connection = createConnection();
let documents = new TextDocuments(TextDocument);
const htmlLanguageService = getLanguageService();
connection.onCompletion((textDocumentPosition) => {
const document = documents.get(textDocumentPosition.textDocument.uri);
const htmlDocument = htmlLanguageService.parseHTMLDocument(document!);
if (htmlDocument.roots.length > 0) {
return htmlLanguageService.doComplete(
document!, textDocumentPosition.position, htmlDocument);
}
});
documents.listen(connection);
connection.listen();
我想知道是否还有另一种简单的方法可以在其中使用HTML及其语言中的VSCode功能。