How to register code snippets for a DSL? #1118
Answered
by
msujew
rhumbertgz
asked this question in
Q&A
-
Hi. I'm using the MonacoEditorReactComp and I can't find a way to register my completion provider. Using the UserConfig I can specify the Monarch syntax highlighting, but there is no option to set my code snippets. Any pointers how to register them? Best regards, |
Beta Was this translation helpful? Give feedback.
Answered by
msujew
Jul 12, 2023
Replies: 1 comment 6 replies
-
Hey @rhumbertgz, we don't have a builtin API for code snippets yet, but you can easily add them yourselves. See the following (inaccurate) example: class CustomCompletionProvider extends DefaultCompletionProvider {
override getCompletion(args): Promise<CompletionList> {
const list = await super.getCompletion(args);
list.items.push({
label: 'snippet',
kind: CompletionItemKind.Snippet,
insertText: '...'
});
return list;
}
} And register that completion provider for your language. |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I believe you're missing the
insertTextFormat: InsertTextFormat.Snippet
property in your returned items. I forgot that you need to set that as well.