-
Hello! Is there a straightforward way to combine two text objects into one? I wish to press require("nvim-treesitter.configs").setup {
textobjects = {
move = {
enable = true,
set_jumps = true,
goto_next_start = { ["]f"] = "@function.outer", ["]c"] = "@class.outer" },
goto_next_end = { ["]F"] = "@function.outer", ["]C"] = "@class.outer" },
goto_previous_start = { ["[f"] = "@function.outer", ["[c"] = "@class.outer" },
goto_previous_end = { ["[F"] = "@function.outer", ["[C"] = "@class.outer" },
},
},
} I tried swapping
or
Can someone please help me? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Found my problem! I was trying to type the query directly in place of the capture name ;; ~/.config/nvim/queries/python/textobjects.scm
; extends
[
(function_definition)
(class_definition)
] @toplevel And then configuring require("nvim-treesitter.configs").setup {
textobjects = {
move = {
enable = true,
set_jumps = true,
goto_next_start = { ["]t"] = "@toplevel" },
goto_next_end = { ["]t"] = "@toplevel" },
goto_previous_start = { ["]t"] = "@toplevel" },
goto_previous_end = { ["]t"] = "@toplevel" },
},
},
} The downside is that now I must write the |
Beta Was this translation helpful? Give feedback.
Found my problem! I was trying to type the query directly in place of the capture name
@function.outer
. I solved it by moving the query to its own file.And then configuring
nvim-treesitter-textobjects
like this.