So I wanted to customize VS Code for some custom language. I made a .json with snippets that I parsed out of all .inc files that I've got with this language but I'd rather want to have it implemented into IntelliSense. So my question is, how to create a custom language IntelliSense support when I have .inc files with all the global variables, functions and so on? I've researched this for a couple of hours now and couldn't find anything that helped me even start.
you need to create a language server and Add code completion feature to it. The example code below adds code completion to the server. It proposes the two words 'TypeScript' and 'JavaScript'
// This handler provides the initial list of the completion items.
connection.onCompletion(
(_textDocumentPosition: TextDocumentPositionParams): CompletionItem[] => {
// The pass parameter contains the position of the text document in
// which code complete got requested. For the example we ignore this
// info and always provide the same completion items.
return [
{
label: 'TypeScript',
kind: CompletionItemKind.Text,
data: 1
},
{
label: 'JavaScript',
kind: CompletionItemKind.Text,
data: 2
}
];
}
);
// This handler resolve additional information for the item selected in
// the completion list.
connection.onCompletionResolve(
(item: CompletionItem): CompletionItem => {
if (item.data === 1) {
(item.detail = 'TypeScript details'),
(item.documentation = 'TypeScript documentation');
} else if (item.data === 2) {
(item.detail = 'JavaScript details'),
(item.documentation = 'JavaScript documentation');
}
return item;
}
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With