In Monaco Editor, using the standard initialization such as:
monaco.editor.create(document.getElementById("container"), {
value: "",
language: "csharp"
});
Will have an out-of-the-box local variables code completion. For example, using the standard initializaton above, and typing the code like this:
string testVariable = "This is a string";
int aValue = 123;
The Code Completion will recognize both "testVariable" and "aValue" variables and show them on the Code Completion list.
But, if we add a registerCompletionItemProvider to the initialization like this:
//Custom Code Completion function
function createCompleters() {
return [
{
label: 'customFunction1',
kind: monaco.languages.CompletionItemKind.Function,
documentation: "My first Custom Function",
insertText: 'customFunction1()'
},
{
label: 'customFunction2',
kind: monaco.languages.CompletionItemKind.Function,
documentation: "My second Custom Function",
insertText: 'customFunction2()'
}
];
}
//Register the custom completion function into Monaco Editor
monaco.languages.registerCompletionItemProvider('csharp', {
provideCompletionItems: function(model, position) {
return createCompleters();
}
});
//Continue with the Standard initialization here...
monaco.editor.create(document.getElementById("container"), {
value: "",
language: "csharp"
});
Then, the local variables is not recognized anymore, only the registered functions are recognized.
How can I register the custom code completion but also still retain the local variables completion? Thanks!