Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not-hardcoded provideCompletionItems #24

Closed
alrod opened this issue Jun 24, 2016 · 3 comments
Closed

Not-hardcoded provideCompletionItems #24

alrod opened this issue Jun 24, 2016 · 3 comments
Assignees

Comments

@alrod
Copy link
Member

alrod commented Jun 24, 2016

Is it possible to call web service in provideCompletionItems to return not-hardcoded/dynamic provideCompletetionItems?

monaco.languages.registerCompletionItemProvider('mySpecialLanguage', {
provideCompletionItems: () => {
return [
{
label: 'simpleText',
kind: monaco.languages.CompletionItemKind.Text
}, {
label: 'testing',
kind: monaco.languages.CompletionItemKind.Keyword,
insertText:'testing({{condition}})'
},
{
label: 'ifelse',
kind: monaco.languages.CompletionItemKind.Snippet,
insertText: [
'if ({{condition}}) {',
'\t{{}}',
'} else {',
'\t',
'}'
].join('\n'),
documentation: 'If-Else Statement'
}
]
}
});
https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-custom-languages

@stofte
Copy link

stofte commented Jun 24, 2016

The API supports returning a promise, inside of which you can perform your lookup.

return new Promise(succ => {
    ajax.then(jsonList => {
        succ(jsonList)
    });
});

instead of returning your array directly.

@alexdima
Copy link
Member

@alrod I have created a sample (it uses a hover provider, but the idea is the same, exactly as @stofte commented):

https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-hover-provider-example

@alexdima alexdima self-assigned this Jun 24, 2016
@alrod
Copy link
Member Author

alrod commented Jun 24, 2016

@alexandrudima , @stofte thanks guys! it works!

@alrod alrod closed this as completed Jun 24, 2016
@vscodebot vscodebot bot locked and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants