Reputation: 250
I want to add numbers to the sass-indentation extension and I kind of figured out how to that, it would be nice if i could set the cursor location when the suggestion gets triggered, just like you can set the cursor location when you make snippets with $1
, is that possible ?
import { CompletionItem, CompletionItemKind } from 'vscode';
const sassSchemaTest = [
{
name: '%',
body: '$1%', // I want the cursor location where the '$' sign is
description: 'test'
}
];
export default sassSchemaTest.map(item => {
const completionItem = new CompletionItem(item.name);
completionItem.insertText = item.body;
completionItem.detail = item.description;
completionItem.kind = CompletionItemKind.Property;
return completionItem;
});
Upvotes: 1
Views: 385
Reputation: 34138
Yes, completion items support the usual snippet syntax. Simply use a vscode.SnippetString
for insertText
instead of a raw string
.
A string or snippet that should be inserted in a document when selecting this completion. When
falsy
the label is used.
completionItem.insertText = new vscode.SnippetString(item.body);
Upvotes: 1