vscode扩展名自定义完整Initem禁用内置的Intellisense
我正在研究VSCODE扩展程序,以便为代码完成提供自定义片段。
我知道直接使用摘要JSON文件的选项,但是这些选项的限制是无法使用启示弹窗口旁边的图标旁边的InterionItemkind属性。
我的问题:
如果我实现了这样的简单完整启动者:
context.subscriptions.push(
vscode.languages.registerCompletionItemProvider(
{scheme:"file",language:"MyLang"},
{
provideCompletionItems(document: vscode.TextDocument, position: vscode.Position) {
let item = new vscode.CompletionItem('test');
item.documentation = 'my test function';
item.kind = vscode.CompletionItemKind.Function;
return [item];
}
}
)
)
那么原始的vscode IntelliSense文本建议不再显示,而只显示了我自己。如果我只是返回一种空的回应,例如
provideCompletionItems(document: vscode.TextDocument, position: vscode.Position) {
return [null|[]|undefined];
}
建议再次出现。在我看来,与其合并内置的IntelliSense和我自己的提供商的结果,内置的提供商会被简单地覆盖。
问题:
在应用自己的postionIniTems时如何保留内置的Intellisense建议?
vscode版本:v1.68.1 ubuntu
I am working on a VsCode extension in that I want to provide custom snippets for code completion.
I know about the option of using snippet json files directly, however those have the limitation of not being able to utilize the CompletionItemKind property that determines the icon next to the completion suggestion in the pop-up.
My issue:
If I implement a simple CompletionItemProvider like this:
context.subscriptions.push(
vscode.languages.registerCompletionItemProvider(
{scheme:"file",language:"MyLang"},
{
provideCompletionItems(document: vscode.TextDocument, position: vscode.Position) {
let item = new vscode.CompletionItem('test');
item.documentation = 'my test function';
item.kind = vscode.CompletionItemKind.Function;
return [item];
}
}
)
)
then the original VsCode IntelliSense text suggestions are not shown anymore, only my own. Should I just return a kind of an empty response, like
provideCompletionItems(document: vscode.TextDocument, position: vscode.Position) {
return [null|[]|undefined];
}
the suggestions appear again as they should. It seems to me that instead of merging the results of the built-in IntelliSense and my own provider, the built-in ones get simply overridden.
Question:
How can I keep the built-in IntelliSense suggestions while applying my own CompletionItems?
VsCode Version: v1.68.1 Ubuntu
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我似乎已经找到了问题的答案,所以我会回答我的问题。
我的提供者似乎提供的结果比Intellisense的评分更高。
由于我没有提供任何触发字符,因此我的完成启动直接与每个按下键内置系统找到的单词并赢得胜利。
我的解决方案是简单地解析并注册单词我自己的文本文章并扩展了我的提供商的结果。如果我愿意,我可能同样可以为他们创建并注册一个新的完整网络培训者,但是我决定为我的项目建立不同的结构。
I seem to have found the answer for my problem, so I will answer my question.
My provider seems to provide results that are just higher scored than those of IntelliSense.
Since I didn't provide any trigger characters, my CompletionItems were comteping directly with the words found by the built-in system by every single pressed key and won.
My solution is to simply parse and register the words in my TextDocument myself and extend my provider results by them. I could probably just as well create and register a new CompletionItemProvider for them if I wanted to, however I decided to have a different structure for my project.