Fix completion item provider sample

pull/1226/head
Alex Dima 2018-11-23 12:40:22 +01:00
parent 094013374c
commit 9af2ead38d
2 changed files with 46 additions and 52 deletions

View File

@ -66,32 +66,29 @@ monaco.editor.defineTheme('myCoolTheme', {
// Register a completion item provider for the new language
monaco.languages.registerCompletionItemProvider('mySpecialLanguage', {
provideCompletionItems: () => {
return [
{
label: 'simpleText',
kind: monaco.languages.CompletionItemKind.Text
}, {
label: 'testing',
kind: monaco.languages.CompletionItemKind.Keyword,
insertText: {
value: 'testing(${1:condition})'
}
},
{
label: 'ifelse',
kind: monaco.languages.CompletionItemKind.Snippet,
insertText: {
value: [
'if (${1:condition}) {',
'\t$0',
'} else {',
'\t',
'}'
].join('\n')
},
documentation: 'If-Else Statement'
}
]
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 };
}
});

View File

@ -28,32 +28,29 @@ monaco.editor.defineTheme('myCoolTheme', {
// Register a completion item provider for the new language
monaco.languages.registerCompletionItemProvider('mySpecialLanguage', {
provideCompletionItems: () => {
return [
{
label: 'simpleText',
kind: monaco.languages.CompletionItemKind.Text
}, {
label: 'testing',
kind: monaco.languages.CompletionItemKind.Keyword,
insertText: {
value: 'testing(${1:condition})'
}
},
{
label: 'ifelse',
kind: monaco.languages.CompletionItemKind.Snippet,
insertText: {
value: [
'if (${1:condition}) {',
'\t$0',
'} else {',
'\t',
'}'
].join('\n')
},
documentation: 'If-Else Statement'
}
]
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 };
}
});