I have tried to create custom language with auto complete ( intellisenses ). It's not working out. can any one help me to achieve this.
Code
https://stackblitz.com/edit/angular-7-master-emjqsr?file=src/app/app.module.ts
You'll need to copy the files from node_modules/monaco-editor/min/vs to your preferred location of choice. Since I'm using ASP.NET Core, I use gulp to copy the files from node_modules to wwwroot/js/vs . Here is condensed sample of how to set up the Monaco Editor, since I could not find a quick start elsewhere.
You're almost there.
You only need to return object like { suggestions: suggestions }
instead of array in your provideCompletionItems
method and you're done:
monaco.languages.registerCompletionItemProvider('dummy', {
provideCompletionItems: () => {
var suggestions = [
{
label: 'simpleText',
kind: monaco.languages.CompletionItemKind.Text,
insertText: 'simpleText',
},
{
label: 'testing',
kind: monaco.languages.CompletionItemKind.Keyword,
insertText: 'testing(${1:condition})',
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
},
{
label: 'ifelse',
kind: monaco.languages.CompletionItemKind.Snippet,
insertText: ['if (${1:condition}) {', '\t$0', '} else {', '\t', '}'].join('\n'),
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
documentation: 'If-Else Statement',
},
];
return { suggestions: suggestions };
},
});
Ng-run Example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With