nvim-treesitter / nvim-treesitter-textobjects

Apache License 2.0
2.2k stars 199 forks source link

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

Open samueloph opened 2 weeks ago

samueloph commented 2 weeks ago

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.