Which method in vscode-languageserver::IConnection
has to be implemented to provide functionality "Go To Definition" over multiple files?
I was studying Language Server Node Example
and vscode "API documentation", but I didn't find any info.
If a language supports it, you can go to the definition of a symbol by pressing F12. Tip: You can jump to the definition with Ctrl+Click or open the definition to the side with Ctrl+Alt+Click.
If you are a keyboard user, place your text cursor somewhere inside the symbol name and press F12. If you are a mouse user, either select Go To Definition from the right-click menu or use the Ctrl-click functionality described in the following section.
You can browse and install extensions from within VS Code. Bring up the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of VS Code or the View: Extensions command (Ctrl+Shift+X). This will show you a list of the most popular VS Code extensions on the VS Code Marketplace.
Place the caret at a symbol in the code viewer or select the symbol in a tool window. Choose Navigate | Go To Implementation in the main menu, press Ctrl+F12 , or click the symbol while holding Ctrl+Alt keys. Note that in Visual Studio 2017 and later, the Ctrl+Alt -click is used for adding multiple carets.
The following code snippet illustrates how to implement "Go To Definition" using vscode-laguageserver
.
connection.onInitialize((params): InitializeResult => {
...
return {
capabilities: {
definitionProvider: true,
...
}
}
});
connection.onDefinition((textDocumentIdentifier: TextDocumentIdentifier): Definition => {
return Location.create(textDocumentIdentifier.uri, {
start: { line: 2, character: 5 },
end: { line: 2, character: 6 }
});
});
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