Open Nanobot567 opened 1 year ago
This is something I've already considered and would like to add in the future. However, I don't know much about how it works and how long it would take.
Maybe this could be of help: http://github.com/nineteendo/tmlx/tree/main/Extension This is a fairly simple syntax highlighter with code completion using a language server (doesn't work on temp files). The suggestions are generated like this:
const suggestions = ['black', 'blue', 'color', 'cyan', 'green', 'magenta', 'red', 'white', 'yellow'].map<CompletionItem>(label => {
return {
label,
kind: CompletionItemKind.Constant,
};
}).concat(['down', 'left', 'right', 'up', 'write'].map(label => {
return {
label,
kind: CompletionItemKind.Function,
};
})).concat(['else', 'exit', 'goto', 'if', 'while'].map(label => {
return {
label,
kind: CompletionItemKind.Keyword,
};
}));
Result:
Though we'll have to decide whether we use snippets for functions or not.
Also, you should probably remove the lower case prefixes for the snippets:
Here is a slightly fancier solution:
const suggestions = [
{
kind: CompletionItemKind.Operator,
items: [
{
label: ' or ',
detail: 'valueA or valueB'
},
{
label: ' xor ',
detail: 'valueA xor valueB'
}
]
},
{
kind: CompletionItemKind.Function,
items: [
{
label: 'Pt-On(',
detail: 'Pt-On(x,y[,mark])'
},
{
label: 'Pt-Off(',
detail: 'Pt-Off(x,y[,mark])'
}
]
}
].flatMap(group =>
group.items.map(item => ({
kind: group.kind,
label: item.label,
detail: item.detail
}))
);
Note that you don't have to provide the detail.
Any updates?
I'm currently pretty busy right now with other stuff and I'm working on importing / exporting in #4 as well, so this is lower priority. I'll make the change to the snippets but since I'm changing some token formats to match this I feel like it makes sense to wait to work on this until after that is done.
Thanks for providing the examples though, that will certainly come in handy when I get around to it :)
You don't have to add this if you don't want to, I just thought it would be a nice addition to the extension :)