nvim-treesitter-textobjects
nvim-treesitter-textobjects copied to clipboard
Ruby @function and @block not working
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
I just tried to use the configuration in the README.md, and I'm seeing this too. I was able to confirm that the mappings do show up in in :nmap <buffer>
at least, but they don't appear to do anything.
I realized the reason my config wasn't working was because nvim-treesitter-textobjects
wasn't actually installed 🤦🏻♂️ I think this is probably particularly easy because how these are keys passed into the treesitter setup, rather than requiring something.
@otavioschwanck I have the same keymaps
as you, and similarly they no longer work. By any chance that you're seeing file read errors if you run :file
after opening a Ruby file running :file
? Removing the keymaps
resolves this issue for me. I noticed that the Ruby queries were updated recently and am going to see if reverting those changes fixes things.
@npezza93 reverting the Ruby queries changes fixes the read errors issue mentioned in my previous comment. I can look into it more tomorrow, but any idea what's going on or how best to go about debugging? Thanks!
Have you pulled in the latest from nvim-treesitter and installed the newest ruby-tree-sitter?
@npezza93 Yes, I've pulled the latest from nvim-treesitter. When you ask whether I've installed the newest ruby-tree-sitter, do you mean the latest Ruby parsers? If so, TSUpdate
show that all parsers are up-to-date.
Looks like this was an issue on my end. Some combination of reinstalling plugins, parsers, etc., to resolve some checkhealth errors seems to have everything working again for me. Thanks!
Hi, for me @function.*
is working while @block.*
is not
@theHamsta, actually the same for me.
I was not able to get this to work for ruby -- is it still the same for others?
Both of these are working for me, I think this ticket can be closed.