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

Viewed 973

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?

1 Answers

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
   }
});
Related