Rewrite core on top of treesitter queries #71
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The current core implementation of nvim-paredit relies on a language extension api to ask questions about the AST.
This is not a very treesitter-like way of doing things and the extension API was pretty gnarly.
This is a complete reimplementation which relies entirely on treesitter queries with known capture groups. This drastically simplifies both the implementation and the task of extending to other languages.
Now, instead of having to understand and write a language API, you can just write a few treesitter queries to help nvim-paredit understand the grammar.
This also reworks some internals:
Currently the approach to checking if a node represents the document root is to check if its type is "source". While a lot of grammars do this by convension it's not part of any spec and some grammars call it something else - like "program".
This replaces all these assertions with a comparison to see if the node is :equal() to the tree :root() which is completely grammar agnostic.