nvim-treesitter / nvim-treesitter/nvim-treesitter-textobjects
Ruby @function and @block not working
Open
Nobody has claimed this yet.
bug
- Dominant language
- Tree-sitter Query
- Stars
- 2.8k
- Forks
- 271
- Avg merge
- 8d 8h
- Merged PRs (30d)
- 1
Description
Using an example class:
class Teste
def method_a # first function
end
def method_b # first function
end
first_block do
end
second_block do
end
end
My setup:
local M = {}
function M.setup()
require'nvim-treesitter.configs'.setup {
ensure_installed = "all",
textobjects = {
move = {
enable = true,
set_jumps = true, -- whether to set jumps in the jumplist
goto_next_start = {
["]c"] = "@class.outer",
["]]"] = "@function.outer",
},
goto_next_end = {
["]C"] = "@class.outer",
["]["] = "@function.outer",
},
goto_previous_start = {
["[c"] = "@class.outer",
["[["] = "@function.outer",
},
goto_previous_end = {
["[C"] = "@class.outer",
["[]"] = "@function.outer",
},
},
rainbow = { enabled = true, extended_mode = true, max_file_lines = 1500 },
select = {
enable = true,
lookahead = true,
keymaps = {
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@class.outer",
["ic"] = "@class.inner",
},
},
},
endwise = {
enable = true,
},
-- List of parsers to ignore installing
ignore_install = { "phpdoc" },
autotag = {
enable = true,
},
-- Install languages synchronously (only applied to `ensure_installed`)
sync_install = false,
indent = { enable = true, disable = { "ruby", "python" } },
highlight = {
enable = true,
},
}
end
return M
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 Ruby example and the nvim-treesitter.configs textobjects setup shown in the issue, focusing on the @function and @block captures used by movement and selection. Reproduce the behavior in Neovim, then verify that the configured mappings move between and select the expected Ruby methods and blocks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua, ruby, vim
- Domain
- devtools, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100