-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat!: use queries for determining context #198
Conversation
2c4a9ed
to
f1ae7bd
Compare
this is awesome :) I'm happy to help testing / reviewing, if needed. Could this also somehow handle the ( I only have basic knowledge of TS queries, so I'm not sure). |
75d5116
to
fca8b2f
Compare
I hope so. I don't fully understand the |
Yes please. Any help is welcome. This is a huge breaking change so I'll just be daily driving this branch for a while. |
Yeah, I don't really understand the last nodes stuff. Can you provide an example of what it does (or should do) and I'll just implement it with queries? |
66ad6fe
to
d8540eb
Compare
I can look up some more details & examples later . From memory: |
Also the I remember by default the context shows the whole line, not only what is covered by the TS node. And in some cases it would skip over things at the start of the line. Since this was only used for PHP I'm not sure if we should invest time into fixing this |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
while playing around with queries I saw that the current implementation will actually merge the whole TS node content into one line, which for the python function example ( |
reading longer, it could be that ( while the problem where would be that the |
I've got a rough idea to solve this by just adding a second capture (or reuse |
3b2fd25
to
086793c
Compare
Just looked at the |
8fa8fee
to
73f606b
Compare
This comment was marked as resolved.
This comment was marked as resolved.
@lewis6991 after the last bugfix I started to use this branch in my day-to-day work, here are some new queries: I'm not sure if every user would like the For example in a multi line function call this would give me the first line of the call: |
Updated both. |
@romgrk I'm thinking of merging this fairly soon. Can you have a look? |
6c48e7b
to
214c428
Compare
a850f2b
to
261f916
Compare
This plugin has been significantly rewritten to use Treesitter queries instead of patterns for determining context regions for languages. The main benefits of this change are: - it is a much simpler implementation since we can leverage core APIs. - it fits in more generally with the Treesitter eco-system. - it allows configuration of contexts to be provided from multiples sources. - it allows more sophisticated configuration of contexts since queries (with directives and predicates) are much more powerful than patterns. - the query format should be usable for other editors. The major downside of this new implementation is that it requires each language to provide it's own query as opposed to using the general purpose patterns. This means that some languages which had contexts before may not have them now. If this is the case then please raise an issue. Adding queries for a specific language is fairly simple but too much work to implement for all 170+ parsers that exist. This commits provides explicit support for: - bash - c - cpp - typescript - rust - json - lua - markdown - python - yaml - php - scala - teal - toml - vim Please see the README for instructions on how to add support for other languages. This commit also drops explicit support for Nvim 0.7. If you still need support for this version then you can use the `compat/0.7` release.
This plugin has been significantly rewritten to use Treesitter queries instead of patterns for determining context regions for languages.
The main benefits of this change are:
The major downside of this new implementation is that it requires each language to provide it's own query as opposed to using the general purpose patterns. This means that some languages which had contexts before may not have them now. If this is the case then please raise an issue. Adding queries for a specific language is fairly simple but too much work to implement for all 170+ parsers that exist.
This commits provides explicit support for:
Please see the README for instructions on how to add support for other languages.
This commit also drops explicit support for Nvim 0.7. If you still need support for this version then you can use the
compat/0.7
release.