看起来如果我创建一个Language Server扩展名是可能的。来自网站:
语言服务器通常实现的第一个有趣功能是验证文档。从这个意义上说,即使是一个linter也算作一个语言服务器,并且在VS代码中,linters通常被实现为语言服务器(参见eslint和jshint的例子)。但是语言服务器还有更多。他们可以提供代码完整,查找所有引用或转到定义。下面的示例代码将代码完成添加到服务器。它只是提出了两个单词'TypeScript'和'JavaScript'。
和一些示例代码:
// This handler provides the initial list of the completion items.
connection.onCompletion((textDocumentPosition: TextDocumentPositionParams): CompletionItem[] => {
// The pass parameter contains the position of the text document in
// which code complete got requested. For the example we ignore this
// info and always provide the same completion items.
return [
{
label: 'TypeScript',
kind: CompletionItemKind.Text,
data: 1
},
{
label: 'JavaScript',
kind: CompletionItemKind.Text,
data: 2
}
]
});
// This handler resolve additional information for the item selected in
// the completion list.
connection.onCompletionResolve((item: CompletionItem): CompletionItem => {
if (item.data === 1) {
item.detail = 'TypeScript details',
item.documentation = 'TypeScript documentation'
} else if (item.data === 2) {
item.detail = 'JavaScript details',
item.documentation = 'JavaScript documentation'
}
return item;
});