I don't see any suggestions
Opened this issue · 4 comments
Hi, I'm using the scheme
language in an electron app.
When I use Ctrl
+Space
I don't see any completion suggestions. Here is my code:
<template>
...
<MonacoEditor
v-model="$store.state.file.content"
class="editor"
theme="vs-dark"
language="scheme"
:options="options"
@change="onChange"
height="100%"
:editorBeforeMount="registerLang"
></MonacoEditor>
...
</template>
<script>
data() {
return {
options: {
//Monaco Editor Options
//minimap:true,
automaticLayout: true,
matchBrackets:"always",
//renderIndentGuides:true,
dragAndDrop:true,
suggest: {
showWords:true
},
suggestOnTriggerCharacters:true,
parameterHints:{
cycle:true,
enabled:true
},
scrollBeyondLastLine:false,
statusBar:{
visible:true
}
},
code:";code",
selectedItem:null
}
},
methods: {
onChange(value) {
//console.log(value);
//send the value to the file
fs.writeFileSync(this.$store.state.file.path,value)
},
registerLang(monaco){
monaco.languages.registerCompletionItemProvider('scheme', {
provideCompletionItems: () => {
var suggestions = [{
label: 'simpleText',
kind: monaco.languages.CompletionItemKind.Text,
insertText: 'simpleText'
}, {
label: 'display',
kind: monaco.languages.CompletionItemKind.Keyword,
insertText: '(display ${1:condition})',
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet
}, {
label: 'if-then-else',
kind: monaco.languages.CompletionItemKind.Snippet,
insertText:'(if ${1:condition} ${2:then} ${3:else})',
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
documentation: 'If-Else Statement'
}];
return { suggestions: suggestions };
}
});
},
}}
</script>
There is no light bulb or popup or any context menu inside the editor. Am I doing something wrong? Thank you!
P.S. I also tried to initialize a new language, but the code I wrote that worked on the playground https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-custom-languages didn't work in the vue component - no highlighting was done. (I did make sure to switch the language and theme names correctly.)
@saumyasinghal747 scheme, are you registered?
Hello, thank you for the response! I'm not sure what you mean by "registered", could you elaborate? Thank you!
I was able to get the default syntax highlighting for scheme, if that's what you mean.
Hello, thank you for the response! I'm not sure what you mean by "registered", could you elaborate? Thank you!
I was able to get the default syntax highlighting for scheme, if that's what you mean.
monaco.languages.register({ id: 'scheme' });
But I was able to get syntax highlighting for scheme, which means it's a predefined language. I didn't even get suggestions for javascript. I did try making a new language earlier, and I did register it under a name other than scheme
since that already existed. I did it in the editorBeforeMount
. But I'm not looking to define a new language anymore, I'm just trying to add on to the predefined scheme
in Monaco. It works in the playground here (select scheme from menu), I get suggestions for basic dictionary words. But no such thing in the Vue component. Thank you!!