问题
I tried to write an extension to vscode to help me import lib by keyboard shortcuts I've tried many things, but two questions remain unanswered
1.How to use CompletionItemProvider by shortcut key
Normally, CompletionItemProvider is triggered by a character,But I want to be able to use the shortcut to bind commands.Ideally, I could press the shortcut to display the CompletionItems directly.But the only thing I know so far is through vscode.com command.excute('trugger suggest'), which can be cluttered with other CompletionItems
2.How to hide other CompletionItems
When trigger the CompletionItemProvider,other options appear . They should come from other extensions .What should I do to display only my own extension options
code:
export function activate(context: vscode.ExtensionContext) {
const provider = vscode.languages.registerCompletionItemProvider({
scheme:"file",
language:"typescript"
}, {
provideCompletionItems(doc, pos) {
return [
new vscode.CompletionItem("1.foo"),
new vscode.CompletionItem("2.bar"),
new vscode.CompletionItem("3.baz")
]
}
})
context.subscriptions.push(provider);
}
result:out of the red box are unnecessary options
来源:https://stackoverflow.com/questions/59941508/how-to-use-vscode-completionitemprovider-by-keybinding