I have a VS Code extension for ST language support. Right now it provides only syntax highlights and some snippets. I wanted to create a tree structure of the document showing programs, functions and their parameters in the Outline panel. But I cannot find an example of how to do that.
Can you refer me to the right direction but not to LSP as it is too complicated for now I want to make it programmatically.
The outline view is populated by a DocumentSymbolProvider
(see also: registerDocumentSymbolProvider()
). In the language server protocol, this corresponds to the textDocument/documentSymbol
request.
All in all, it currently provides the data for all of these:
- Outline view
- Breadcrumbs
- Go to Symbol in File
You can find an example implementation of one here, though you'll want it to return DocumentSymbol
rather than SymbolInformation
instances. Only the former supports the hierarchy needed for the outline view via it's children
property.
来源:https://stackoverflow.com/questions/57131265/how-to-add-elements-to-outline-panel-in-custom-extension