I am in the process of writing an extension for a custom language in Visual Studio Code. Syntax detection is working well via the tmLanguage file. I am trying to figure out how to add intellisense and go to symbol support, neither of which I have been able to find clear documentation on nor reference file(s) to work from.
When I have a file open with my custom language selected and I select go to symbol I get the following error: Unfortunately we have no symbol information for the file.
Is there any documentation, or can you provide some tips on how to get started, or do we know that these options are not available for custom languages?
@Wosi is correct but he refers the API preview. Since the Nov-release you want to implement a WorkspaceSymbolProvider
(https://code.visualstudio.com/docs/extensionAPI/vscode-api#WorkspaceSymbolProvider) to achieve this.
You can find how we did it TypeScript here and this is how to register the feature. Basically provide a provideWorkspaceSymbols
function that given a search string returns a list of symbols.
Go to any symbol in workspace: Implement a WorkspaceSymbolProvider
and register it in your extension's main.js like this
function registerSupports(modeID, host, client) {
vscode.languages.registerWorkspaceSymbolProvider(new WorkspaceSymbolProvider(client, modeID));
}
Go to symbol (at current cursor position): Implement a DefinitionProvider
and register it in your extension's main.js like this
function registerSupports(modeID, host, client) {
vscode.languages.registerDefinitionProvider(modeID, new DeclarationSupport(client));
}
IntelliSense: Implement a CompletionItemProvider
and register it in your extension's main.js like this
function registerSupports(modeID, host, client) {
vscode.languages.registerCompletionItemProvider(modeID, new SuggestSupport(client), '.');
}
See also HelloWorld extension and Language server example.
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