我已经尝试创建具有自动完成功能(intellisenses)的自定义语言。它没有解决。谁能帮助我实现这一目标。
代码
https://stackblitz.com/edit/angular-7-master-emjqsr?file=src/app/app.module.ts
您快到了。
您只需要返回{ suggestions: suggestions }
之类的对象,而不是provideCompletionItems
方法中的数组,就可以完成:
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 };
},
});