-
Notifications
You must be signed in to change notification settings - Fork 42
Description
Hello,
This is a feature request that could make other extension developers quite happy and solve quite a few issues related to interacting with source code. It would be great if there were API endpoints allowing other developers to make custom queries on the parsed Treesitter tree and thus allow them to navigate the AST more freely.
At the moment if someone decided to do relatively simple things like:
- Knowing if the cursor is presently inside a string
- Knowing where a function begins and ends
- Get the location in the text of matching brackets
all require extension developers to make their own custom parsers only to reimplement existing VSCode's functionalities. This is probably unnecessary duplication and the end result is often worse than the existing VSCode's implementation. Unfortunately at the moment the VSCode's API does not give a proper access to the AST and tokens produced during parsing (this github issue elaborates on the subject). There is a useful command called vscode.executeDocumentSymbolProvider but it is not enough and does not always categorize symbols properly: see this issue
Treesitter and Anycode could probably solve this problem by parsing the tree once on document changes and then giving it access to other extensions to query on their own. Would this be possible?
Thank you