nvim-treesitter / nvim-treesitter/nvim-treesitter-textobjects
Distinguish between methods and 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.
I want a way to distinguish between methods and functions in JavaScript and other languages.
Describe the solution you'd like
I'd like:
goto_next_start = {
["]k"] = "@class.outer",
["]m"] = "(method_definition) @function",
["]f"] = "@function.outer",
["]b"] = "@block.outer",
}
to work (I realize I'm not specifying javascript for ]m but I was just testing it out before cleaning it up.
Describe alternatives you've considered
None
Additional context
I'd like to do something like this eventually:
goto_next_start = {
["]k"] = "@class.outer",
["]m"] = {
javascript: "(method_definition) @function",
java = "(method_declaration) @function",
"@function.outer"
}
["]f"] = "@function.outer",
["]b"] = "@block.outer",
}
So that I can correctly move from method to method in the languages I most often work with and fall back to the more generic solution when an override isn't defined.
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 by tracing how the goto_next_start configuration is read and how Tree-sitter captures such as @function and (method_definition) are handled. Confirm that language-specific method queries can override the generic function query for JavaScript and Java, while retaining the generic fallback.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, javascript, lua, neovim
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100