adding the method arguments, so it is obvious how to make the completion item context sensitive by reaching into the document.getText() and using the position etc...

This commit is contained in:
Jan Dolejsi
2017-12-13 22:01:22 +01:00
parent 7b9c376aad
commit ab26257a51

View File

@ -13,7 +13,7 @@ export function activate(context: vscode.ExtensionContext) {
// * return the 'Hello World' and
// a snippet-based completion item.
vscode.languages.registerCompletionItemProvider('plaintext', {
provideCompletionItems() {
provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, context: vscode.CompletionContext) {
return [
new vscode.CompletionItem('Hello World!'),
createSnippetItem()
@ -31,7 +31,7 @@ export function activate(context: vscode.ExtensionContext) {
// https://code.visualstudio.com/docs/editor/userdefinedsnippets#_creating-your-own-snippets
let item = new vscode.CompletionItem('Good part of the day', vscode.CompletionItemKind.Snippet);
item.insertText = new vscode.SnippetString("Good ${1|morning,afternoon,evening|}.");
item.insertText = new vscode.SnippetString("Good ${1|morning,afternoon,evening|}. It is ${1}, right?");
item.documentation = new vscode.MarkdownString("Inserts a snippet that lets you select the _appropriate_ part of the day for your greeting.");
return item;