Skip to content
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

Allow/document to jump to beginning/end of functions #713

Open
samueloph opened this issue Nov 5, 2024 · 1 comment
Open

Allow/document to jump to beginning/end of functions #713

samueloph opened this issue Nov 5, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@samueloph
Copy link

Is your feature request related to a problem? Please describe.
One of the most useful motions for me is being able to jump to the beginning/end of a function. Unfortunately, using neovim's native ]m and ]M doesn't work for every language/file (https://neovim.io/doc/user/motion.html#%5Bm), as it doesn't uses treesitter.

Describe the solution you'd like
I would like a solution that lets me jump to beginning/end of function/class using treesitter's objects.
If this is already supported by the plugin, I would like it to be listed in the README examples, as I don't know how to make it behave like that.
I'm looking for something that overrides ]m and ]M using treesitter's objects.

Describe alternatives you've considered
The keymaps for ["af"] = "@function.outer", ["if"] = "@function.inner", are almost a perfect match of what I'm looking for, so I try to use them whenever possible. I would like something that can replace the ]m [m [M ]M motions though.

Additional context
I'm a bit new to treesitter, so if this doesn't sound like a reasonable request, let me know.

@samueloph samueloph added the enhancement New feature or request label Nov 5, 2024
@carlos-algms
Copy link

It's a reasonable idea, and I've tried to achieve it multiple times since I installed this plugin.

you can add:

goto_next_start = {
    ["]m"] = "@function.outer",
}

But it would go to a sibling start, not the parent function, like the af or if does.

It would be great to have something like: goto_parent_start and goto_parent_end jumps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants