-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add tree-sitter based function, class navigation #1619
Add tree-sitter based function, class navigation #1619
Conversation
e627caf
to
5647995
Compare
I was thinking |
How would we handle for comment navigation when I add that? Should that use around, or be more granular? What if we gave the user a choice by doing something like:
|
This was what I initially wanted to do, but I ran into some problems. We would probably need something similar to neovim's custom
I think around would work fine for it too, since then we can navigate by comment blocks, which seems intuitive. If we use inside for comment navigation each single line comment would be a separate node and there
That IMO adds a bit too much verbosity that doesn't seem very useful since you can always use |
@sudormrfbin ok, agreed on all counts. What about introducing a new subcapture meant specifically for this? Something like
I just tested this out in PHP with tree-sitter-cli and it did indeed allow multiple captures on the same nodes (so @function.around and @function.movement were both captured and both corresponded to the same items):
|
I'm also having trouble getting the parameter movements to work in PHP and Rust files after checking out this PR and trying it out. Functions and classes work beautifully. Edit: of course it doesn't work we haven't implemented the parameter thing yet! Ignore my comment. |
Added an |
book/src/usage.md
Outdated
See the [unimpaired][unimpaired-keybinds] section of the keybind | ||
documentation for the full reference. | ||
|
||
> NOTE: This feature is dependant on tree-sitter based textobjects |
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.
> NOTE: This feature is dependant on tree-sitter based textobjects | |
> NOTE: This feature is dependent on tree-sitter based textobjects |
book/src/usage.md
Outdated
some grammars](https://github.com/search?q=repo%3Ahelix-editor%2Fhelix+filename%3Atextobjects.scm&type=Code&ref=advsearch&l=&l=) | ||
currently have the query file implemented. Contributions are welcome ! | ||
some grammars][lang-support] currently have the query file implemented. | ||
Contributions are welcome ! |
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.
Contributions are welcome ! | |
Contributions are welcome! |
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.
Looks good, just needs a rebase 👍🏻
a143795
to
74ff2be
Compare
Adds support for navigating between functions, classes, etc, using tree-sitter and textobjects. Requires that a
*.around
capture is defined for a filetype in it's correspodingtextobjects.scm
file. So for goto next function to work in Rust,function.around
textobject has to be defined in Rust'stextobjects.scm
.Added keybinds (click to expand)
]f
[f
]c
[c
]p
[p
Open questions
parameter.around
is not defined in any query file, so]p
is not very useful.