我可以将完成 (Intellisense) 文件添加到语言支持扩展吗?
Can I Add a Completions (Intellisense) File to a Language Support Extension?
我正在通过转换 Sublime tmBundle 为 VS Code 开发语言支持扩展。我正在使用来自 siteleaf/liquid-syntax-mode 的捆绑包。我已使用 yo code
选项 4 和 5 成功包含以下内容并合并输出:
- 语法文件(
.tmLanguage
)
- 片段(
.sublime-snippet
)
我想做的是通过导入 .sublime-completions
文件来添加 autocomplete/Intellisense 支持,直接导入或以某种方式重写它。
是否可以在 VS Code 中向 autocomplete/Intellisense 添加项目?
如果我创建一个 Language Server 扩展似乎是可能的。来自网站:
The first interesting feature a language server usually implements is validation of documents. In that sense, even a linter counts as a language server and in VS Code linters are usually implemented as language servers (see eslint and jshint for examples). But there is more to language servers. They can provide code complete, Find All References or Go To Definition. The example code below adds code completion to the server. It simply proposes the two words 'TypeScript' and '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;
});
我正在通过转换 Sublime tmBundle 为 VS Code 开发语言支持扩展。我正在使用来自 siteleaf/liquid-syntax-mode 的捆绑包。我已使用 yo code
选项 4 和 5 成功包含以下内容并合并输出:
- 语法文件(
.tmLanguage
) - 片段(
.sublime-snippet
)
我想做的是通过导入 .sublime-completions
文件来添加 autocomplete/Intellisense 支持,直接导入或以某种方式重写它。
是否可以在 VS Code 中向 autocomplete/Intellisense 添加项目?
如果我创建一个 Language Server 扩展似乎是可能的。来自网站:
The first interesting feature a language server usually implements is validation of documents. In that sense, even a linter counts as a language server and in VS Code linters are usually implemented as language servers (see eslint and jshint for examples). But there is more to language servers. They can provide code complete, Find All References or Go To Definition. The example code below adds code completion to the server. It simply proposes the two words 'TypeScript' and '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;
});