-
Notifications
You must be signed in to change notification settings - Fork 242
Add @parameter.outer for Python/C/C++ #23
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
Conversation
970f75d to
8e07a86
Compare
|
@andreypopp could you test this? and maybe even add the queries for you favorite language? |
|
Wow! Testing it with python. It works well with argument lists which have the trailing comma but with the following one: It cannot extract a range from (no trailing coma after I've tried to match on |
|
But did you apply the patch in the description for nvim-treesitter? This should handle the nil case. |
|
Oops, I apologize, I missed that requirement. It works that way! I actually tried to patch nvim-treesitter the same way but thought that it's a bit non intuitive behaviour. What if the range's intent is to cover more than two siblings? In case |
|
Is that bad? If b is not captured the query can not know about it. What you would like to have in that situation would be the ternary We have a lot of stuff that can be optionally carry a something before or after it. |
idk, probably not bad... Another idea — I think it could be a useful in API to specify an open range.. something like To result in: |
|
By the way "open ranges" could with another thing — I've wanted to try to redefine |
|
Yes, with the new You should be able to implement |
|
With this Last is actually only necessary since the |
|
I created a bug report regarding the last (tree-sitter/tree-sitter#806). Would be nice if we could specify |
stsewd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I try to add @stsewd select next textobject soon to make it also work on spaces before the parameter
Thanks, I said I'd do it, but been busy lately :(
|
@theHamsta don know if you’ve seen but I made a PR to your fork with this text object for JavaScript |
c0915b0 to
f119414
Compare
|
@theHamsta This is really nice! 🎉 What would it take to be able to also make it work on spaces before the argument? I could try to look into it but just started with treesitter so would be happy to hear any advice :) Similarly it would be great to make it so that when one does e.g. |
If we can add this support then I can completely remove targets.vim from my plugin list. As far as I know Tree Sitter doesn't mark whitespaces as nodes, so one possible approach would be looking for next sibling in the parameter_list and select all the way to that sibling, which effectively deletes the whitespaces. Edit: typo |
|
@liujoey PRs are welcome 🙂 |
Addresses: #22
Requires: nvim-treesitter/nvim-treesitter#657
It only works if your cursor is between the parameter or and the end character of the ",". I try to add @stsewd select next textobject soon to make it also work on spaces before the parameter