Odysseas
Odysseas

Reputation: 1060

How to allow completion suggestions to appear while inside a snippet in Monaco Editor?

I am using the monaco-editor library to implement a web editor for a custom programming language.

I have implemented a CompletionItemProvider to provide custom completion suggestions.

It works great in general. However, while a snippet is being executed (for example, while the user is typing in the "$1" placeholder of the snippet), completion suggestions are not shown, and the user has to press Ctrl+Space for them to appear.

This related issue describes the problem and its solution for the Visual Studio Code editor itself, but how can completion suggestions be allowed during snippet completion, when using the monaco-editor library?

Upvotes: 3

Views: 2414

Answers (1)

Odysseas
Odysseas

Reputation: 1060

When creating the editor instance, provide the suggest editor option, with snippetsPreventQuickSuggestions set to false, as shown below:

const editor = monaco.editor.create(element, {
   value: value,
   language: myLanguageId,
   theme: myThemeId,
   suggest: {
      snippetsPreventQuickSuggestions: false
   }
});

Upvotes: 5

Related Questions