Pra*_*avi 7 javascript typescript visual-studio-code vscode-extensions
我有一个用例,我有一种语言 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();
}
Run Code Online (Sandbox Code Playgroud)
这不起作用。我猜想,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();
Run Code Online (Sandbox Code Playgroud)
是否有另一种简单的方法可以在我的语言中使用 HTML 及其 VSCode 功能?
| 归档时间: |
|
| 查看次数: |
422 次 |
| 最近记录: |