Skip to content

Combining multiple text objects #598

Closed Answered by leiteg
leiteg asked this question in Q&A
Discussion options

You must be logged in to vote

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.

;; ~/.config/nvim/queries/python/textobjects.scm
; extends
[
  (function_definition)
  (class_definition)
] @toplevel

And then configuring nvim-treesitter-textobjects like this.

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

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by leiteg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant