nvim-treesitter / nvim-treesitter/nvim-treesitter-textobjects
Allow/document to jump to beginning/end of functions
Nobody has claimed this yet.
- Dominant language
- Tree-sitter Query
- Stars
- 2.8k
- Forks
- 271
- Avg merge
- 8d 8h
- Merged PRs (30d)
- 1
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the README examples and the existing textobjects keymap documentation, then compare Neovim's native [m, ]m, [M, and ]M motions with the @function.outer and @function.inner mappings mentioned in the issue. Done means the requested function/class boundary motions are supported or clearly documented, with behavior verified across the relevant Tree-sitter objects.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100