Giter Site home page Giter Site logo

nvim-treesitter-textobjects's Introduction

nvim-treesitter-textobjects

Syntax aware text-objects, select, move, swap, and peek support.

Warning: tree-sitter and nvim-treesitter are an experimental feature of nightly versions of Neovim. Please consider the experience with this plug-in as experimental until tree-sitter support in Neovim is stable! We recommend using the nightly builds of Neovim or the latest stable version.

Installation

You can install nvim-treesitter-textobjects with your favorite package manager, or using the default pack feature of Neovim!

Using a package manager

If you are using vim-plug, put this in your init.vim file:

Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'nvim-treesitter/nvim-treesitter-textobjects'

If you are using Packer, put it in your init.lua file:

use({
  "nvim-treesitter/nvim-treesitter-textobjects",
  after = "nvim-treesitter",
  requires = "nvim-treesitter/nvim-treesitter",
})

Text objects: select

Define your own text objects mappings similar to ip (inner paragraph) and ap (a paragraph).

lua <<EOF
require'nvim-treesitter.configs'.setup {
  textobjects = {
    select = {
      enable = true,

      -- Automatically jump forward to textobj, similar to targets.vim
      lookahead = true,

      keymaps = {
        -- You can use the capture groups defined in textobjects.scm
        ["af"] = "@function.outer",
        ["if"] = "@function.inner",
        ["ac"] = "@class.outer",
        -- You can optionally set descriptions to the mappings (used in the desc parameter of
        -- nvim_buf_set_keymap) which plugins like which-key display
        ["ic"] = { query = "@class.inner", desc = "Select inner part of a class region" },
        -- You can also use captures from other query groups like `locals.scm`
        ["as"] = { query = "@scope", query_group = "locals", desc = "Select language scope" },
      },
      -- You can choose the select mode (default is charwise 'v')
      --
      -- Can also be a function which gets passed a table with the keys
      -- * query_string: eg '@function.inner'
      -- * method: eg 'v' or 'o'
      -- and should return the mode ('v', 'V', or '<c-v>') or a table
      -- mapping query_strings to modes.
      selection_modes = {
        ['@parameter.outer'] = 'v', -- charwise
        ['@function.outer'] = 'V', -- linewise
        ['@class.outer'] = '<c-v>', -- blockwise
      },
      -- If you set this to `true` (default is `false`) then any textobject is
      -- extended to include preceding or succeeding whitespace. Succeeding
      -- whitespace has priority in order to act similarly to eg the built-in
      -- `ap`.
      --
      -- Can also be a function which gets passed a table with the keys
      -- * query_string: eg '@function.inner'
      -- * selection_mode: eg 'v'
      -- and should return true or false
      include_surrounding_whitespace = true,
    },
  },
}
EOF

Text objects: swap

Define your own mappings to swap the node under the cursor with the next or previous one, like function parameters or arguments.

lua <<EOF
require'nvim-treesitter.configs'.setup {
  textobjects = {
    swap = {
      enable = true,
      swap_next = {
        ["<leader>a"] = "@parameter.inner",
      },
      swap_previous = {
        ["<leader>A"] = "@parameter.inner",
      },
    },
  },
}
EOF

Text objects: move

Define your own mappings to jump to the next or previous text object. This is similar to ]m, [m, ]M, [M Neovim's mappings to jump to the next or previous function.

lua <<EOF
require'nvim-treesitter.configs'.setup {
  textobjects = {
    move = {
      enable = true,
      set_jumps = true, -- whether to set jumps in the jumplist
      goto_next_start = {
        ["]m"] = "@function.outer",
        ["]]"] = { query = "@class.outer", desc = "Next class start" },
        --
        -- You can use regex matching (i.e. lua pattern) and/or pass a list in a "query" key to group multiple queires.
        ["]o"] = "@loop.*",
        -- ["]o"] = { query = { "@loop.inner", "@loop.outer" } }
        --
        -- You can pass a query group to use query from `queries/<lang>/<query_group>.scm file in your runtime path.
        -- Below example nvim-treesitter's `locals.scm` and `folds.scm`. They also provide highlights.scm and indent.scm.
        ["]s"] = { query = "@scope", query_group = "locals", desc = "Next scope" },
        ["]z"] = { query = "@fold", query_group = "folds", desc = "Next fold" },
      },
      goto_next_end = {
        ["]M"] = "@function.outer",
        ["]["] = "@class.outer",
      },
      goto_previous_start = {
        ["[m"] = "@function.outer",
        ["[["] = "@class.outer",
      },
      goto_previous_end = {
        ["[M"] = "@function.outer",
        ["[]"] = "@class.outer",
      },
      -- Below will go to either the start or the end, whichever is closer.
      -- Use if you want more granular movements
      -- Make it even more gradual by adding multiple queries and regex.
      goto_next = {
        ["]d"] = "@conditional.outer",
      },
      goto_previous = {
        ["[d"] = "@conditional.outer",
      }
    },
  },
}
EOF

You can make the movements repeatable like ; and ,.

local ts_repeat_move = require "nvim-treesitter.textobjects.repeatable_move"

-- Repeat movement with ; and ,
-- ensure ; goes forward and , goes backward regardless of the last direction
vim.keymap.set({ "n", "x", "o" }, ";", ts_repeat_move.repeat_last_move_next)
vim.keymap.set({ "n", "x", "o" }, ",", ts_repeat_move.repeat_last_move_previous)

-- vim way: ; goes to the direction you were moving.
-- vim.keymap.set({ "n", "x", "o" }, ";", ts_repeat_move.repeat_last_move)
-- vim.keymap.set({ "n", "x", "o" }, ",", ts_repeat_move.repeat_last_move_opposite)

-- Optionally, make builtin f, F, t, T also repeatable with ; and ,
vim.keymap.set({ "n", "x", "o" }, "f", ts_repeat_move.builtin_f)
vim.keymap.set({ "n", "x", "o" }, "F", ts_repeat_move.builtin_F)
vim.keymap.set({ "n", "x", "o" }, "t", ts_repeat_move.builtin_t)
vim.keymap.set({ "n", "x", "o" }, "T", ts_repeat_move.builtin_T)

You can even make a custom repeat behaviour.

-- This repeats the last query with always previous direction and to the start of the range.
vim.keymap.set({ "n", "x", "o" }, "<home>", function()
  ts_repeat_move.repeat_last_move({forward = false, start = true})
end)

-- This repeats the last query with always next direction and to the end of the range.
vim.keymap.set({ "n", "x", "o" }, "<end>", function()
  ts_repeat_move.repeat_last_move({forward = true, start = false})
end)

Furthermore, you can make any custom movements (e.g. from another plugin) repeatable with the same keys. This doesn't need to be treesitter-related.

-- example: make gitsigns.nvim movement repeatable with ; and , keys.
local gs = require("gitsigns")

-- make sure forward function comes first
local next_hunk_repeat, prev_hunk_repeat = ts_repeat_move.make_repeatable_move_pair(gs.next_hunk, gs.prev_hunk)
-- Or, use `make_repeatable_move` or `set_last_move` functions for more control. See the code for instructions.

vim.keymap.set({ "n", "x", "o" }, "]h", next_hunk_repeat)
vim.keymap.set({ "n", "x", "o" }, "[h", prev_hunk_repeat)

Alternative way is to use a repeatable movement managing plugin such as nvim-next.

Textobjects: LSP interop

  • peek_definition_code: show textobject surrounding definition as determined using Neovim's built-in LSP in a floating window. Press the shortcut twice to enter the floating window.
lua <<EOF
require'nvim-treesitter.configs'.setup {
  textobjects = {
    lsp_interop = {
      enable = true,
      border = 'none',
      floating_preview_opts = {},
      peek_definition_code = {
        ["<leader>df"] = "@function.outer",
        ["<leader>dF"] = "@class.outer",
      },
    },
  },
}
EOF

Overriding or extending textobjects

Textobjects are defined in the textobjects.scm files. You can extend or override those files by following the instructions at https://github.com/nvim-treesitter/nvim-treesitter#adding-queries. You can also use a custom capture for your own textobjects, and use it in any of the textobject modules, for example:

-- after/queries/python/textobjects.scm
; extends
(function_definition) @custom_capture
lua <<EOF
require'nvim-treesitter.configs'.setup {
  textobjects = {
    select = {
      enable = true,
      keymaps = {
        -- Your custom capture.
        ["aF"] = "@custom_capture",

        -- Built-in captures.
        ["af"] = "@function.outer",
        ["if"] = "@function.inner",
      },
    },
  },
}
EOF

Here are some rules about the query names that should be noted.

  1. Avoid using special characters in the query name, because in move module the names are read as regex (lua) patterns.
  • @custom-capture.inner (X)
  • @custom_capture.inner (O)
  1. In select module, it will be preferred to select within the @*.outer matches. For example,
  • @assignment.inner, @assignment.lhs, and even @assignment will be selected within the @assignment.outer range if available. This means it will sometimes look behind.
  • You can write something like @function.name or @call.name and make sure @function.outer and @call.outer covers the range.

Built-in Textobjects

  1. @assignment.inner
  2. @assignment.lhs
  3. @assignment.outer
  4. @assignment.rhs
  5. @attribute.inner
  6. @attribute.outer
  7. @block.inner
  8. @block.outer
  9. @call.inner
  10. @call.outer
  11. @class.inner
  12. @class.outer
  13. @comment.inner
  14. @comment.outer
  15. @conditional.inner
  16. @conditional.outer
  17. @frame.inner
  18. @frame.outer
  19. @function.inner
  20. @function.outer
  21. @loop.inner
  22. @loop.outer
  23. @number.inner
  24. @parameter.inner
  25. @parameter.outer
  26. @regex.inner
  27. @regex.outer
  28. @return.inner
  29. @return.outer
  30. @scopename.inner
  31. @statement.outer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
apex🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
astro⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ 🟩 ⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
bash🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ 🟩 ⬜ ⬜ ⬜ ⬜ ⬜
bibtex⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩
c🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 ⬜ 🟩
c_sharp⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
cmake⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ ⬜ ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
cpp🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 ⬜ 🟩
css🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
cuda🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 ⬜ 🟩
dart⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ 🟩
dockerfile⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
elixir⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ ⬜
elm⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 ⬜ ⬜ ⬜ 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
fennel⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ ⬜ ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩
fish🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ 🟩 ⬜ 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 ⬜ 🟩 ⬜ ⬜ 🟩 🟩 ⬜ 🟩
foam⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ ⬜ ⬜ 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
glsl🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 ⬜ 🟩
go🟩 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ 🟩
hack⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
haskell⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
hcl🟩 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ 🟩 🟩 🟩 ⬜ ⬜ ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ 🟩
heex⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
hlsl🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 ⬜ 🟩
html⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ 🟩 ⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
java⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
javascript🟩 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ ⬜
julia⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ ⬜
kotlin⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
latex⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ 🟩 ⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
lua🟩 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 ⬜ ⬜
matlab⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ 🟩 ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 ⬜ 🟩
nasm⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ 🟩 ⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ ⬜ ⬜ 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
nim🟩 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 ⬜ 🟩
nix⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
odin🟩 🟩 🟩 🟩 🟩 🟩 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ 🟩 ⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 ⬜ ⬜
perl⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 ⬜ ⬜ ⬜ ⬜
php⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ 🟩
php_only⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ 🟩
python🟩 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 ⬜ 🟩
ql⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 ⬜
r🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ ⬜ ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ 🟩
readline⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩
rst⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ ⬜ 🟩 🟩 ⬜ 🟩 ⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
ruby⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ ⬜ 🟩 🟩 ⬜ 🟩 ⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ ⬜
rust🟩 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 ⬜ 🟩
scala⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 ⬜ ⬜ ⬜ 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
scss🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
slang🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 ⬜ 🟩
supercollider⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ ⬜ 🟩 🟩 ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
swift⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ 🟩 ⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ ⬜ ⬜ 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
terraform🟩 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ 🟩 🟩 🟩 ⬜ ⬜ ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ 🟩
toml⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
tsx🟩 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ ⬜
twig⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ 🟩
typescript🟩 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ ⬜
v🟩 🟩 ⬜ 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 ⬜ 🟩
verilog⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 ⬜ ⬜ ⬜ 🟩 ⬜ 🟩 ⬜ 🟩 ⬜ ⬜ ⬜ 🟩 ⬜ 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
vim🟩 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 ⬜ 🟩 ⬜ ⬜ ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ 🟩
vue⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 ⬜ ⬜ ⬜ ⬜ 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
wgsl⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 ⬜ ⬜ 🟩 🟩 ⬜ ⬜ 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
wgsl_bevy⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 ⬜ ⬜ 🟩 🟩 ⬜ ⬜ 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜
yaml🟩 🟩 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩
zig⬜ ⬜ ⬜ ⬜ ⬜ ⬜ 🟩 🟩 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 🟩 ⬜ ⬜ 🟩 🟩 🟩 🟩 ⬜ 🟩 🟩 ⬜ ⬜ ⬜ ⬜ ⬜ 🟩

nvim-treesitter-textobjects's People

Contributors

acksld avatar aspeddro avatar clason avatar echasnovski avatar fsouza avatar gbprod avatar genesistms avatar ghostbuster91 avatar indianboy42 avatar jacfger avatar kiyoon avatar laytan avatar luathn avatar mike325 avatar mrcjkb avatar npezza93 avatar observeroftime avatar pockata avatar pwntester avatar qsdrqs avatar ranjithshegde avatar ribru17 avatar rrethy avatar savq avatar sevanteri avatar skbolton avatar stsewd avatar swoogan avatar thehamsta avatar yochem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nvim-treesitter-textobjects's Issues

Allow linewise selection

Is your feature request related to a problem? Please describe.
When attempting to make linewise selection of a textobject (for example, with Vaf for function.outer) I expect it to become linewise selection. Instead it is forced to be a regular selection (like an outcome of vaf). This is a consequence of how nvim-treesitter.ts_utils.update_selection() operates: it selects exactly the textobject forcing regular visual selection.

Linewise selection is useful, for example, when you want to delete lines with indented function definition.

Describe the solution you'd like
Making explicit linewise visual selection possible.

Describe alternatives you've considered
Technically, adding extra V keystroke solves the issue: vafV forces linewise selection. However, it seems to present a little unnecessary cognitive load compared to regular vim experience.

Additional context
I will make a PR which utilizes the equivalence of expected Vaf and vafV.

different approach to defining keybindings?

Is your feature request related to a problem? Please describe.
A lot of the time when defining selections and movements, I run into conflicts with default vim bindings or other plugins. Debugging such situations is pretty tough, since the current way of configuring bindings (via the map) is opaque.

Describe the solution you'd like
Instead of creating bindings via the map, perhaps there's a way to expose the motions as commands, or some other format, where the user can assign them to bindings through a more standard mechanism, like nvim_set_keymap. For example, https://github.com/neovim/nvim-lspconfig defines a bunch of functions and asks users to create bindings via something like:

buf_set_keymap("n", "<leader>t", [[<Cmd>lua vim.lsp.buf.hover()<CR>]], opts)

I think this is pretty straightforward for things like "move" commands, but I'm not sure whether it will work for things like "select".

Cannot delete parameter in tsx files but works fine with ts files

Describe the bug
Does not work with tsx files, only ts

To Reproduce
Use the following configuration:

require'nvim-treesitter.configs'.setup {                                                                        
  ensure_installed = {"typescript", "tsx", "javascript"},                                            
  highlight = { enable = true },                                                                                
  textobjects = {
    select = {                                                                                                  
      enable = true,                                                                                            
      lookahead = true,
      keymaps = {
        ["af"] = "@function.outer", 
        ["if"] = "@function.inner",
        ["ac"] = "@class.outer",
        ["ic"] = "@class.inner",
        ["ap"] = "@parameter.outer",                                                                            
        ["ip"] = "@parameter.inner",                                                                            
      },                                                                                                        
    },                                                                                                          
  },                                                                                                            
}  

Open tsx file with a function definition like:

function blah(arg: string, arg2: string): string {
  return arg + arg2;
}

Put the cursor over the first a in arg: and then use dip to delete the parameter.

This will work fine in a ts file, but not at all in a tsx file.

Output of :checkhealth nvim_treesitter

health#nvim_treesitter#check
======================================================================== ## Installation

  • OK: tree-sitter found 0.20.0 (parser generator, only needed for :TSInstallFromGrammar)
  • OK: node found v14.15.4 (only needed for :TSInstallFromGrammar)
  • OK: git executable found. - OK: cc executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl" }
  • OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI.

Parser/Features H L F I J

  • tsx βœ“ βœ“ βœ“ βœ“ βœ“
  • c_sharp βœ“ βœ“ βœ“ . βœ“
  • c βœ“ βœ“ βœ“ βœ“ βœ“
  • javascript βœ“ βœ“ βœ“ βœ“ βœ“
  • typescript βœ“ βœ“ βœ“ βœ“ βœ“

Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
+) multiple parsers found, only one will be used
x) errors found in the query, try to run :TSUpdate {lang}

Output of nvim --version

NVIM v0.6.0-dev+43-g02bf251bb
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compiled by runner@fv-az87-55

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/share/nvim"

Run :checkhealth for more info

How to make TSTextobjectSelect command work with <cmd> in visual mode?

Hey guys,
I prefer to use <cmd> for my mappings in general for all the documented benefits (always clean commands, no silent required, performance, clean command history, ...). Unfortunately this does not work for the TSTextobjectSelect command in visual mode.

This mapping does not work. The result is that the visual selections gets quit and and cursor jumps to the end of the textobject (here the function).

vnoremap af <cmd>TSTextobjectSelect @function.outer<CR>

But it works if I write the mapping like this:

vnoremap af :<C-u>TSTextobjectSelect @function.outer<CR>

Is it possible to patch the command to work with the <cmd> mapping syntax?

Is it possible to make parameter.outer take the previous comma, if there is no comma afterwards

Is your feature request related to a problem? Please describe.
Given an argument list A, B, C, D the parameter.outer objects would be A,; B,; C, and D. This means that daa (delete around argument) would leave a trailing comma that has to be manually deleted

Describe the solution you'd like
It would be great if it could detect the last argument in the list specially and extend it backward to get the preceding comma

Performance

Describe the bug

Current search for textobjects is too slow and could be more flexible (counts, textobjects in same line).

Solution

Avoid iter_prepared_matches in find_best_match. Use find_best_matches to allow the use of v:count

Hotkey for custom query does not work

Describe the bug
Hotkey for query does not capture block.

I have this query set to fold docstrings for Python in my own little plugin so I can be certain the query captures correctly.
(function_definition body: (block (expression_statement (string) @docstring)))

I have also tested this with my plugin enabled/disabled.

I have tried this with capture groups @docstring, @comment, @comment.inner, @comment.outer

I have tried with multi line and single line string.

To Reproduce

# Python file with docstring to yank
def f():
   """ Some text
   
   With more to follow
   """
   return 3 + 3
# My configuration
require('nvim-treesitter.configs') .setup({
   ...,
   textobjects = {
     select = {
        keymaps = {
          ...,                    
          ["c"] = {
            python = "(function_definition body: (block (expression_statement (string) @comment.outer)))"
          }
        }
      }
    }
   ...,
})

Expected behavior
Using yid, the documentation block should be yanked

Output of :checkhealth nvim_treesitter

nvim_treesitter: health#nvim_treesitter#check

Installation

  • OK: tree-sitter found 0.20.0 (parser generator, only needed for :TSInstallFromGrammar)
  • WARNING: node executable not found (only needed for :TSInstallFromGrammar, not required for :TSInstall)
  • OK: git executable found.
  • OK: cc executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
    Version: cc (GCC) 11.1.0
  • OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI.

Parser/Features H L F I J

  • python βœ“ βœ“ βœ“ βœ“ βœ“
  • c βœ“ βœ“ βœ“ βœ“ βœ“
  • lua βœ“ βœ“ βœ“ βœ“ βœ“
  • query βœ“ βœ“ βœ“ βœ“ βœ“

Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
+) multiple parsers found, only one will be used
x) errors found in the query, try to run :TSUpdate {lang}

Output of nvim --version

NVIM v0.7.0-dev+734-g51306f98b
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by root@skantify

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/share/nvim"

Run :checkhealth for more info

Additional context
Using nvim-treesitter-playground I can be certain this query highlights the documentation block.

Screenshot_2021-12-21_16-49-58

textobjects declaration feature request

e.g.
@declaration.outer (the target is whole declaration)
ζˆͺ屏2021-04-08 δΈ‹εˆ10 38 35

@declaration.inner (the target is whole value)
ζˆͺ屏2021-04-08 δΈ‹εˆ10 38 50

and more like const, var, let, window.value = 123...

Refined incremental selection

Although the original incremental selection is good, it can be improved. It goes from the very bottom to the top, which can be tedious sometimes. Leveraging text objects, we can ensure that what we select are always that text object we specified earlier.

Refined incremental selection work this way:
User type some command that specify a text object and enter visual mode.
When user increase or decrease the node in the syntax tree, he can only reach a new text object (or syntax structure) that can match the query.

I have some time and I'm happy to contribute this feature. XD

Make @comment.outer span multiline comment

Is your feature request related to a problem? Please describe.
Code comments are usually hard-wrapped, so I use gw / gq to reflow long multiline comments when editing them. Unfortunately, when these are not separated by an empty line from preceding and following code, then the ip (inner paragraph) text object includes that as well, so gwip / gqip reflows even the code (which is unwanted and very probably wrong). So you have to resort to first visually selecting the comment and then gw / gq.

Describe the solution you'd like
I'd love to use treesitter + @comment.outer to invoke gw / gq over the appropriate range of text. However, @comment.outer currently doesn't span multiline comments, it only extends to the current line. Would it be realistic to redefine it, so that e.g. gwac (if ac is configured as the @comment.outer text object) reflows the entire multiline comment?

Describe alternatives you've considered
If redefining @comment.outer is doable but not desirable for backwards compatibility reasons, then maybe a new textobject could be provided, something like @multiline_comment.outer?

Additional context
I'm specifically interesting in Python, but once a solution exists for one language, it should be fairly easy to extend it to other ones with similar syntax?

Defining my own textobjects as shown in docs isn't working

Describe the bug
I am unable to define custom textobjects for the select submodule.

To Reproduce
Config:

  require'nvim-treesitter.configs'.setup {
    textobjects = {
      select = {
        enable = true,
        keymaps = {
          -- Or you can define your own textobjects like this
          ["iF"] = {
            python = "(function_definition) @function",
            cpp = "(function_definition) @function",
            c = "(function_definition) @function",
            java = "(method_declaration) @function",
          },
        },
      },
    },
  }

C file:

int foo() {
}

Doing viF results in E5108: Error executing lua ...ckpack/opt/nvim-treesitter/lua/nvim-treesitter/query.lua:144: attempt to index local 'query' (a nil value).

Expected behavior

I expect the function to be selected.

Output of :checkhealth nvim_treesitter

health#nvim_treesitter#check

Installation

  • OK: tree-sitter found 0.19.4 (4e321f34a0688f2ad0ce6ec32d0700b039e8436c) (parser generator, only needed for :TSInstallFromGrammar)
  • OK: node found v12.16.3 (only needed for :TSInstallFromGrammar)
  • OK: git executable found.
  • OK: cc executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl" }
  • OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI.

Parser/Features H L F I

  • swift . . . .
  • fortran βœ“ . βœ“ .
  • c_sharp βœ“ . . .
  • rust βœ“ βœ“ βœ“ βœ“
  • go βœ“ βœ“ βœ“ βœ“
  • ledger βœ“ . βœ“ βœ“
  • ruby βœ“ βœ“ βœ“ βœ“
  • zig βœ“ βœ“ βœ“ βœ“
  • rst βœ“ βœ“ . .
  • bibtex βœ“ . βœ“ βœ“
  • fennel βœ“ βœ“ . .
  • latex βœ“ . βœ“ .
  • teal βœ“ βœ“ βœ“ βœ“
  • gomod βœ“ . . .
  • beancount βœ“ . βœ“ .
  • graphql βœ“ . . βœ“
  • r βœ“ βœ“ . .
  • glimmer βœ“ . . .
  • verilog βœ“ βœ“ βœ“ .
  • jsonc βœ“ βœ“ βœ“ βœ“
  • bash βœ“ βœ“ βœ“ .
  • elm . . . .
  • c βœ“ βœ“ βœ“ βœ“
  • comment βœ“ . . .
  • dart βœ“ βœ“ . βœ“
  • fish βœ“ βœ“ βœ“ βœ“
  • sparql βœ“ βœ“ βœ“ βœ“
  • query βœ“ βœ“ βœ“ βœ“
  • jsdoc βœ“ . . .
  • php x x βœ“ βœ“
  • regex βœ“ . . .
  • ql βœ“ βœ“ . βœ“
  • gdscript x x . .
  • nix x x x .
  • typescript βœ“ βœ“ βœ“ βœ“
  • yaml x x βœ“ βœ“
  • turtle βœ“ βœ“ βœ“ βœ“
  • html βœ“ βœ“ βœ“ βœ“
  • devicetree x x x x
  • julia βœ“ βœ“ βœ“ .
  • json βœ“ βœ“ βœ“ βœ“
  • javascript βœ“ βœ“ βœ“ βœ“
  • svelte x . βœ“ βœ“
  • css βœ“ . βœ“ βœ“
  • supercollider x x x x
  • scss βœ“ . . βœ“
  • haskell . . . .
  • erlang . . . .
  • toml βœ“ βœ“ βœ“ βœ“
  • scala . . . .
  • elixir βœ“ βœ“ . βœ“
  • tsx βœ“ βœ“ βœ“ βœ“
  • clojure βœ“ βœ“ βœ“ .
  • kotlin βœ“ . . .
  • ocaml x βœ“ βœ“ .
  • commonlisp βœ“ βœ“ βœ“ .
  • vue βœ“ . βœ“ .
  • python βœ“ βœ“ βœ“ βœ“
  • lua βœ“ βœ“ βœ“ βœ“
  • ocaml_interfacex βœ“ βœ“ .
  • java x βœ“ . βœ“
  • cpp βœ“ βœ“ βœ“ βœ“
  • ocamllex x . . .
  • dockerfile βœ“ . . .

Legend: H[ighlight], L[ocals], F[olds], I[ndents]
+) multiple parsers found, only one will be used
x) errors found in the query, try to run :TSUpdate {lang}

The following errors have been detected:

  • ERROR: php(highlights): /usr/local/share/nvim/runtime/lua/vim/treesitter/query.lua:161: query: invalid node type at position 100
  • ERROR: php(locals): /usr/local/share/nvim/runtime/lua/vim/treesitter/query.lua:161: query: invalid node type at position 987
  • ERROR: gdscript(highlights): ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /Users/rethy/.local/share/nvim/site/pack/backpack/opt/nvim-treesitter/parser/gdscript.so: supported between 13 and 13, found 12
  • ERROR: gdscript(locals): ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /Users/rethy/.local/share/nvim/site/pack/backpack/opt/nvim-treesitter/parser/gdscript.so: supported between 13 and 13, found 12
  • ERROR: nix(highlights): ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /Users/rethy/.local/share/nvim/site/pack/backpack/opt/nvim-treesitter/parser/nix.so: supported between 13 and 13, found 12
  • ERROR: nix(locals): ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /Users/rethy/.local/share/nvim/site/pack/backpack/opt/nvim-treesitter/parser/nix.so: supported between 13 and 13, found 12
  • ERROR: nix(folds): ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /Users/rethy/.local/share/nvim/site/pack/backpack/opt/nvim-treesitter/parser/nix.so: supported between 13 and 13, found 12
  • ERROR: yaml(highlights): /usr/local/share/nvim/runtime/lua/vim/treesitter/query.lua:161: query: invalid node type at position 291
  • ERROR: yaml(locals): /usr/local/share/nvim/runtime/lua/vim/treesitter/query.lua:161: query: invalid node type at position 20
  • ERROR: devicetree(highlights): ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /Users/rethy/.local/share/nvim/site/pack/backpack/opt/nvim-treesitter/parser/devicetree.so: supported between 13 and 13, found 12
  • ERROR: devicetree(locals): ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /Users/rethy/.local/share/nvim/site/pack/backpack/opt/nvim-treesitter/parser/devicetree.so: supported between 13 and 13, found 12
  • ERROR: devicetree(folds): ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /Users/rethy/.local/share/nvim/site/pack/backpack/opt/nvim-treesitter/parser/devicetree.so: supported between 13 and 13, found 12
  • ERROR: devicetree(indents): ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /Users/rethy/.local/share/nvim/site/pack/backpack/opt/nvim-treesitter/parser/devicetree.so: supported between 13 and 13, found 12
  • ERROR: svelte(highlights): /usr/local/share/nvim/runtime/lua/vim/treesitter/query.lua:161: query: invalid node type at position 17
  • ERROR: supercollider(highlights): ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /Users/rethy/.local/share/nvim/site/pack/backpack/opt/nvim-treesitter/parser/supercollider.so: supported between 13 and 13, found 12
  • ERROR: supercollider(locals): ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /Users/rethy/.local/share/nvim/site/pack/backpack/opt/nvim-treesitter/parser/supercollider.so: supported between 13 and 13, found 12
  • ERROR: supercollider(folds): ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /Users/rethy/.local/share/nvim/site/pack/backpack/opt/nvim-treesitter/parser/supercollider.so: supported between 13 and 13, found 12
  • ERROR: supercollider(indents): ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /Users/rethy/.local/share/nvim/site/pack/backpack/opt/nvim-treesitter/parser/supercollider.so: supported between 13 and 13, found 12
  • ERROR: ocaml(highlights): /usr/local/share/nvim/runtime/lua/vim/treesitter/query.lua:161: query: invalid node type at position 2729
  • ERROR: ocaml_interface(highlights): /usr/local/share/nvim/runtime/lua/vim/treesitter/query.lua:161: query: invalid node type at position 2729
  • ERROR: java(highlights): /usr/local/share/nvim/runtime/lua/vim/treesitter/query.lua:161: query: invalid node type at position 2209
  • ERROR: ocamllex(highlights): ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:33: ABI version mismatch for /Users/rethy/.local/share/nvim/site/pack/backpack/opt/nvim-treesitter/parser/ocamllex.so: supported between 13 and 13, found 11

Output of nvim --version

NVIM v0.5.0-dev+1311-gf8173df4d
Build type: Debug
LuaJIT 2.1.0-beta3
Compilation: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=1 -I/Users/rethy/neovim/build/config -I/Users/rethy/neovim/src -I/Users/rethy/neovim/.deps/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include -I/Library/Frameworks/Mono.framework/Headers -I/Users/rethy/neovim/build/src/nvim/auto -I/Users/rethy/neovim/build/include
Compiled by [email protected]

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/share/nvim"

Run :checkhealth for more info

Additional context
I looked at the code and I don't think it should work unless I misunderstand the following snippet:

shared.lua

    local parser = parsers.get_parser(bufnr, lang)

    parser:for_each_tree(function(tree, lang_tree)
      local lang = lang_tree:lang()
      local start_row, _, end_row, _ = tree:root():range()
      local query = queries.get_query(lang, 'textobjects')
      for m in queries.iter_prepared_matches(query, tree:root(), bufnr, start_row, end_row) do
        for _, n in pairs(m) do
          if n.node then
            table.insert(matches, n)
          end
        end
      end
    end)

Can't use select and yank textobjects

Describe the bug
I used python, but can't select or yank the function with keybinding such as v or y.
when put the cursor in a function, :lua print(vim.inspect(require'nvim-treesitter.query'.collect_group_results(0, 'textobject')))
return {}, but use command like :TSTextobjectSelect @function.outer visually select all function
To Reproduce
Steps to reproduce the behavior:

  1. Install plugin and python parser
  2. Put cursor in python 's function
  3. For example, press vif (which i binded if for "@function.inner") doesn't visually select inner function
    Expected behavior
    Press vif select inner function

Output of :checkhealth nvim_treesitter

Parser/Features H L F I

  • python βœ“ βœ“ βœ“ βœ“

Output of nvim --version

NVIM v0.5.0-dev+1186-g8665a96b9
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compiled by runner@fv-az67-513

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/home/runner/work/neovim/neovim/build/nvim.AppDir/usr/share/nvim"

Run :checkhealth for more info

Additional context
Add any other context about the problem here.

Per mapping/object options

Features like #150 and #125 would benefit from being per-mapping/objects instead of global options.

Our current settings look like this

      keymaps = {
        ["af"] = "@function.outer",
        ["if"] = "@function.inner",
        ["ac"] = "@class.outer",
        ["ic"] = "@class.inner",
      }

We could extend them to something like

-- Global options are defined here
-- lookahead = true,
keymaps = {
  ["af"] = {
    textobject = "@function.outer",
    -- If these options aren't given the global/default ones
    -- are used.
    lookahead = true,
    auto_expand = true,
  },
  -- This form is valid, and it uses the global options.
  ["if"] = "@function.inner"
}

Distinguish between methods and functions

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.

Duplicate help tag

Describe the bug
Help tags are duplicated from nvim-treesitter:

Error generating helptags:
Vim(helptags):E154: Duplicate tag "nvim-treesitter-text-objects-move-submod" in file ...
$ rg nvim-treesitter-text-objects-move-submod

nvim-treesitter/nvim-treesitter/doc/nvim-treesitter.txt
356:                                    *nvim-treesitter-text-objects-move-submod*

nvim-treesitter/nvim-treesitter-textobjects/doc/nvim-treesitter-textobjects.txt
77:                                    *nvim-treesitter-text-objects-move-submod*

Feature request: extend swap functionality to also work on comma separated lists

nvim-treesitter-textobjects has the the ability to swap function arguments. I have previously been using vim-argumentative, which also does this (without the use of tree-sitter). However, vim-argumentative is also able to swap the positions of items in lists. For instance, with the cursor on item foo in the following example, pressing >, moves foo from the first index to the second one like so: [foo, bar, baz] --> [bar, foo, baz].

Would this be possible to impement using tree-sitter?

I personally use the following config for swap:

swap = {
  enable = true,
  swap_next = {
    ['>,'] = '@parameter.inner',
  },
  swap_previous = {
    ['<,'] = '@parameter.inner',
  }
}

What I would want is for >, to swap both parameters and list items like in my previous example.

Edit: I realized after posting that #86 is a very similar question.

Question: is it expected that inner function objects include braces?

(Thanks for the plugin: it is a snap to set up and easy to work with so far.)

I was surprised to see that by default, an inner function object in, for example, Go and Javascript includes the braces. I'm guessing that this is expected behavior and probably a result of how treesitter itself works. But I wanted to confirm that before going further.

I ask because my most common use for inner function objects is that I want to change, delete, or yank all the code in the function body, but in those cases I don't normally want to include the braces. So, I'll need to consider whether it's possible to tweak treesitter's results.

Lazy loading

Describe the bug
I am trying to set up lazy loading of treesitter with packer.nvim and there is a race condition with doing so.
As a result keymapping for textobjects are not loaded.

To Reproduce
A piece of packer config:

  use {
    "nvim-treesitter/nvim-treesitter",
    run = ":TSUpdate",
    requires = {
      {
        "nvim-treesitter/playground",
        after = "nvim-treesitter",
        cmd = { "TSPlaygroundToggle", "TSHighlightCapturesUnderCursor" },
      },
      {
        "nvim-treesitter/nvim-treesitter-textobjects",
        module = "nvim-treesitter-textobjects",
        after = "nvim-treesitter",
      },
    },
    event = "BufRead",
    config = function()
      require "config.treesitter"
    end,
  }

config.treesitter file:

local swap_next, swap_prev = (function()
  local swap_objects = {
    c = "@class.outer",
    f = "@function.outer",
    b = "@block.outer",
    s = "@statement.outer",
    p = "@parameter.inner",
    m = "@call.outer",
  }

  local n, p = {}, {}
  for key, obj in pairs(swap_objects) do
    n[string.format("<leader>s%s", key)] = obj
    p[string.format("<leader>S%s", key)] = obj
  end

  return n, p
end)()

require("nvim-treesitter.configs").setup {
  ensure_installed = "maintained",
  highlight = {
    enable = true,
  },
  indent = {
    enable = true,
    disable = { "yaml" },
  },
  incremental_selection = {
    enable = true,
    keymaps = {
      init_selection = "<enter>",
      node_incremental = "<enter>",
      node_decremental = "<bs>",
    },
  },
  textobjects = {
    select = {
      enable = true,
      -- Automatically jump forward to textobj, similar to targets.vim
      lookahead = true,
      keymaps = {
        -- You can use the capture groups defined in textobjects.scm
        ["oc"] = "@class.outer",
        ["ic"] = "@class.inner",
        ["of"] = "@function.outer",
        ["if"] = "@function.inner",
        ["ob"] = "@block.outer",
        ["ib"] = "@block.inner",
        ["ol"] = "@loop.outer",
        ["il"] = "@loop.inner",
        ["os"] = "@statement.outer",
        ["is"] = "@statement.inner",
        ["oC"] = "@comment.outer",
        ["iC"] = "@comment.inner",
        ["om"] = "@call.outer",
        ["im"] = "@call.inner",
      },
    },
    swap = {
      enable = true,
      swap_next = swap_next,
      swap_previous = swap_prev,
    },
    move = {
      enable = true,
      set_jumps = true, -- whether to set jumps in the jumplist
      goto_next_start = {
        ["]m"] = "@function.outer",
        ["]]"] = "@class.outer",
      },
      goto_next_end = {
        ["]M"] = "@function.outer",
        ["]["] = "@class.outer",
      },
      goto_previous_start = {
        ["[m"] = "@function.outer",
        ["[["] = "@class.outer",
      },
      goto_previous_end = {
        ["[M"] = "@function.outer",
        ["[]"] = "@class.outer",
      },
    },
  },
  playground = {
    enable = true,
    disable = {},
    updatetime = 25,
    persist_queries = false,
  },
}

As far as I understand what is going on is:

  • treesitter is loaded (on BufRead) with the keymappings.
  • playground and textobjects are loaded AFTER keymappings were set up and as a result no keymapping are actually appied to the plugin.

Expected behavior
Keymapping from config.treesitter must be applied to the plugin.

Output of :checkhealth nvim_treesitter

health#nvim_treesitter#check

Installation

  • WARNING: tree-sitter executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
  • OK: node found v14.17.1 (only needed for :TSInstallFromGrammar)
  • OK: git executable found.
  • OK: cc executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl" }
  • OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI.

Output of nvim --version

NVIM v0.6.0-dev+116-g35041432b

Is there a way to lazy load the plugin with packer.nvim?

Error in Rust textobjects

Describe the bug

Error detected while processing FileType Autocommands for "*":
E5108: Error executing lua /usr/local/share/nvim/runtime/lua/vim/treesitter/query.lua:119: query: error at position 440

To Reproduce
Steps to reproduce the behavior:

  1. Open rust file

Expected behavior
no error

Output of :checkhealth nvim_treesitter

health#nvim_treesitter#check

Installation

  • OK: git executable found.
  • OK: cc executable found.

elm parser healthcheck

c parser healthcheck

teal parser healthcheck

java parser healthcheck

python parser healthcheck

dart parser healthcheck

lua parser healthcheck

  • OK: lua parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: folds.scm found.
  • OK: indents.scm found.

ocaml parser healthcheck

go parser healthcheck

nix parser healthcheck

yaml parser healthcheck

json parser healthcheck

jsdoc parser healthcheck

php parser healthcheck

clojure parser healthcheck

html parser healthcheck

typescript parser healthcheck

fennel parser healthcheck

swift parser healthcheck

regex parser healthcheck

query parser healthcheck

verilog parser healthcheck

cpp parser healthcheck

ql parser healthcheck

rst parser healthcheck

ruby parser healthcheck

vue parser healthcheck

ocamllex parser healthcheck

scala parser healthcheck

toml parser healthcheck

rust parser healthcheck

bash parser healthcheck

ocaml_interface parser healthcheck

javascript parser healthcheck

css parser healthcheck

julia parser healthcheck

graphql parser healthcheck

haskell parser healthcheck

c_sharp parser healthcheck

tsx parser healthcheck

Output of nvim --version

NVIM v0.5.0-901-gf5e0f1796
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/sharks/source/neovim/build/config -I/home/sharks/source/neovim/src -I/home/sharks/source/neovim/.deps/usr/include -I/usr/include -I/home/sharks/source/neovim/build/src/nvim/auto -I/home/sharks/source/neovim/build/include

Additional context
Add any other context about the problem here.

Even after enabling the plugin can't select the function

Describe the bug
I used python, go etc, but can't select or yank the function

To Reproduce
Steps to reproduce the behavior:

  1. Install plugin
  2. intall respective language
  3. enable the plugin
  4. can't use key- mapping like no effect In pressing the key mappings

Expected behavior
select or yank the function

Output of :checkhealth nvim_treesitter

Installation

  • OK: git executable found.
  • OK: cc executable found.

javascript parser healthcheck

  • OK: javascript parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: folds.scm found.
  • OK: indents.scm found.

json parser healthcheck

  • OK: json parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: folds.scm found.
  • OK: indents.scm found.

clojure parser healthcheck

toml parser healthcheck

  • OK: toml parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: folds.scm found.
  • OK: indents.scm found.

rust parser healthcheck

  • OK: rust parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: folds.scm found.
  • OK: indents.scm found.

ql parser healthcheck

graphql parser healthcheck

python parser healthcheck

  • OK: python parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: folds.scm found.
  • OK: indents.scm found.

teal parser healthcheck

  • OK: teal parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: folds.scm found.
  • OK: indents.scm found.

go parser healthcheck

  • OK: go parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: folds.scm found.
  • OK: indents.scm found.

kotlin parser healthcheck

c parser healthcheck

  • OK: c parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: folds.scm found.
  • OK: indents.scm found.

turtle parser healthcheck

  • OK: turtle parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: folds.scm found.
  • OK: indents.scm found.

gdscript parser healthcheck

sparql parser healthcheck

  • OK: sparql parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: folds.scm found.
  • OK: indents.scm found.

jsdoc parser healthcheck

regex parser healthcheck

fennel parser healthcheck

Paste the output here

error navigating markdown

Describe the bug

Error when trying to navigate markdown file using text objects

To Reproduce

markdown file like this

# Heading

Text

configuration like this:

      ...
      goto_previous_end = {
        ['[]'] = '@class.outer',
      },

Hit [], error out:

E5108: Error executing lua ...r/start/nvim-treesitter/lua/nvim-treesitter/ts_utils.lua:389: Column value outside range
stack traceback:
        [C]: in function 'nvim_win_set_cursor'
        ...r/start/nvim-treesitter/lua/nvim-treesitter/ts_utils.lua:389: in function 'goto_node'
        ...ter-textobjects/lua/nvim-treesitter/textobjects/move.lua:47: in function 'move'
        ...ter-textobjects/lua/nvim-treesitter/textobjects/move.lua:60: in function 'goto_previous_end'
        [string ":lua"]:1: in main chunk

Expected behavior

Cursor is moved, no error.

Output of :checkhealth nvim_treesitter

nvim_treesitter: health#nvim_treesitter#check ======================================================================== ## Installation - OK: `tree-sitter` found 0.20.1 (062421dece3315bd6f228ad6d468cba083d0a2d5) (parser generator, only needed for :TSInstallFromGrammar) - OK: `node` found v15.14.0 (only needed for :TSInstallFromGrammar) - OK: `git` executable found. - OK: `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" } Version: cc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 - OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI.

Parser/Features H L F I J

  • json βœ“ βœ“ βœ“ βœ“ .-
  • vim βœ“ βœ“ . . βœ“-
  • haskell βœ“ . . . βœ“-
  • supercollider βœ“ βœ“ βœ“ βœ“ βœ“-
  • scala βœ“ . βœ“ . βœ“-
  • go βœ“ βœ“ βœ“ βœ“ βœ“-
  • prisma βœ“ . . . .-
  • tsx βœ“ βœ“ βœ“ βœ“ βœ“-
  • typescript βœ“ βœ“ βœ“ βœ“ βœ“-
  • r βœ“ βœ“ . . .-
  • c_sharp βœ“ βœ“ βœ“ . βœ“-
  • swift . . . . .-
  • cmake βœ“ . βœ“ . .-
  • ocamllex βœ“ . . . βœ“-
  • zig βœ“ . βœ“ βœ“ βœ“-
  • ocaml_interfaceβœ“ βœ“ βœ“ . βœ“-
  • ocaml βœ“ βœ“ βœ“ . βœ“-
  • bibtex βœ“ . βœ“ βœ“ .-
  • heex βœ“ . βœ“ βœ“ βœ“-
  • make βœ“ . . . βœ“-
  • surface βœ“ . βœ“ βœ“ βœ“-
  • elixir βœ“ βœ“ βœ“ βœ“ βœ“-
  • erlang . . . . .-
  • svelte βœ“ . βœ“ βœ“ βœ“-
  • scss βœ“ . . βœ“ .-
  • dockerfile βœ“ . . . βœ“-
  • devicetree βœ“ βœ“ βœ“ βœ“ βœ“-
  • glsl βœ“ βœ“ βœ“ βœ“ βœ“-
  • julia βœ“ βœ“ βœ“ βœ“ βœ“-
  • d βœ“ . βœ“ βœ“ βœ“-
  • cuda βœ“ βœ“ βœ“ βœ“ βœ“-
  • kotlin βœ“ . . . βœ“-
  • cpp βœ“ βœ“ βœ“ βœ“ βœ“-
  • commonlisp βœ“ βœ“ βœ“ . .-
  • php βœ“ βœ“ βœ“ βœ“ βœ“-
  • clojure βœ“ βœ“ βœ“ . βœ“-
  • sparql βœ“ βœ“ βœ“ βœ“ βœ“-
  • fish βœ“ βœ“ βœ“ βœ“ βœ“-
  • bash βœ“ βœ“ βœ“ . βœ“-
  • jsdoc βœ“ . . . .-
  • javascript βœ“ βœ“ βœ“ βœ“ βœ“-
  • perl βœ“ . . . .-
  • comment βœ“ . . . .-
  • ruby βœ“ βœ“ βœ“ βœ“ βœ“-
  • graphql βœ“ . . βœ“ βœ“-
  • verilog βœ“ βœ“ βœ“ . βœ“-
  • ql βœ“ βœ“ . βœ“ βœ“-
  • teal βœ“ βœ“ βœ“ βœ“ βœ“-
  • python βœ“ βœ“ βœ“ βœ“ βœ“-
  • fennel βœ“ βœ“ . . βœ“-
  • rst βœ“ βœ“ . . βœ“-
  • regex βœ“ . . . .-
  • dart βœ“ βœ“ . βœ“ βœ“-
  • fusion βœ“ βœ“ . . .-
  • nix βœ“ βœ“ βœ“ . βœ“-
  • rust βœ“ βœ“ βœ“ βœ“ βœ“-
  • yang βœ“ . βœ“ . .-
  • http βœ“ . . . βœ“-
  • llvm βœ“ . . . .-
  • yaml βœ“ βœ“ βœ“ βœ“ βœ“-
  • hjson βœ“ βœ“ βœ“ βœ“ βœ“-
  • elm βœ“ . . . βœ“-
  • pioasm βœ“ . . . βœ“-
  • json5 βœ“ . . . βœ“-
  • fortran βœ“ . βœ“ βœ“ .-
  • jsonc βœ“ βœ“ βœ“ βœ“ βœ“-
  • latex βœ“ . βœ“ . βœ“-
  • vue βœ“ . βœ“ βœ“ βœ“-
  • beancount βœ“ . βœ“ . .-
  • pug βœ“ . . . βœ“-
  • turtle βœ“ βœ“ βœ“ βœ“ βœ“-
  • godot_resource βœ“ βœ“ βœ“ . .-
  • gdscript βœ“ βœ“ . . βœ“-
  • query βœ“ βœ“ βœ“ βœ“ βœ“-
  • ledger βœ“ . βœ“ βœ“ βœ“-
  • java βœ“ βœ“ . βœ“ βœ“-
  • glimmer βœ“ . . . .-
  • lua βœ“ βœ“ βœ“ βœ“ βœ“-
  • c βœ“ βœ“ βœ“ βœ“ βœ“-
  • toml βœ“ βœ“ βœ“ βœ“ βœ“-
  • html βœ“ βœ“ βœ“ βœ“ βœ“-
  • dot βœ“ . . . βœ“-
  • css βœ“ . βœ“ βœ“ βœ“-
  • tlaplus βœ“ . βœ“ . βœ“-
  • hcl βœ“ . βœ“ βœ“ βœ“-
  • markdown βœ“ . . . βœ“-
  • gomod βœ“ . . . βœ“-
  • gowork βœ“ . . . βœ“-

Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
+) multiple parsers found, only one will be used
x) errors found in the query, try to run :TSUpdate {lang}

Output of nvim --version

NVIM v0.7.0-dev+751-g67bb01ae2
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/dch/neovim/build/config -I/home/dch/neovim/src -I/home/dch/neovim/.deps/usr/include -I/usr/include -I/home/dch/neovim/build/src/nvim/auto -I/home/dch/neovim/build/include
Compiled by dch@DESKTOP-NA4O3IV

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/home/dch/.local/nvim/share/nvim"

Run :checkhealth for more info

Easier option to define mapping manually

Hey guys,

thank you very much for your great work on all the treesitter features! I highly appreciate it! πŸ™

Is your feature request related to a problem? Please describe.

I must admit that I was never a friend of letting a plugin doing the key mappings for me. Also if it allows me to define a configuration option to define the key-combo to use. I feel like having less control, it becomes unstructured and ugly. At least that is my view. Unfortunately it seems to become a pattern for the more recent Lua'ish plugins to push for this kind of mappings.
So I denied to use the map definitions within the initialization step of this plugin. I'm adding them manually by myself where they belong to (from my perspective). Unfortunately this results in incredible long lines which look like this for example:

vnoremap <silent> af :<C-u>lua require'nvim-treesitter.textobjects.select'.select_textobject('@function.outer')<CR>

Talking about code quality this results into a fail that is hard to read, because 80% is equal boilerplate code. It is hard to see what is the actual relevant configuration here.

Describe the solution you'd like
I wanted to ask if you guys are willed to add a simple command for each of those exposed functions. Just something as simple as api.nvim_command('command! TSTextObjectSelect lua require..... This would make it slightly easier to add such mappings by hand, removing a lot of the boilerplate.


I'm also open to get suggestions how I could improve my mappings else.
Thank you very much in advanced!

Text Objects are not being set at all

Describe the bug
The text objects I set are non-existent. When I try the bindings within the configuration (at the bottom), nothing happens. There's no error messages or anything like that. It is as if they weren't set. Thanks for any help

Expected behavior
I was expecting the text objects to be selected, cleared, etc when I acted upon them

Output of :checkhealth nvim_treesitter

health#nvim_treesitter#check ======================================================================== ## Installation - WARNING: `tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall) - OK: `node` found v16.4.1 (only needed for :TSInstallFromGrammar) - OK: `git` executable found. - OK: `gcc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl" } - OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI.

Parser/Features H L F I J

  • python βœ“ βœ“ βœ“ βœ“ βœ“
  • haskell βœ“ . . . βœ“
  • yaml βœ“ βœ“ βœ“ βœ“ βœ“
  • javascript βœ“ βœ“ βœ“ βœ“ βœ“
  • commonlisp βœ“ βœ“ βœ“ . .
  • json βœ“ βœ“ βœ“ βœ“ .
  • rust βœ“ βœ“ βœ“ βœ“ βœ“
  • c βœ“ βœ“ βœ“ βœ“ βœ“
  • html βœ“ βœ“ βœ“ βœ“ βœ“
  • css βœ“ . βœ“ βœ“ βœ“
  • lua βœ“ βœ“ βœ“ βœ“ βœ“

Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
+) multiple parsers found, only one will be used
x) errors found in the query, try to run :TSUpdate {lang}

Output of nvim --version

NVIM v0.6.0-dev+98-ga5c25e4f3
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe /DWIN32 /D_WINDOWS /W3 -DNVIM_TS_HAS_SET_MATCH_LIMIT /MD /Zi /O2 /Ob1 /DNDEBUG /W3 -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -DWIN32 -D_WIN32_WINNT=0x0600 -DINCLUDE_GENERATED_DECLARATIONS -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -ID:/a/neovim/neovim/build/config -ID:/a/neovim/neovim/src -ID:/a/neovim/neovim/nvim-deps/usr/include -ID:/a/neovim/neovim/build/src/nvim/auto -ID:/a/neovim/neovim/build/include
Compiled by runneradmin@fv-az152-272

Features: -acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM\sysinit.vim"
  fall-back for $VIM: "C:/Program Files/nvim/share/nvim"

Run :checkhealth for more info

Additional context
My Text Objects Configuration

-- ...
textobjects = {
    lsp_interop = { enable = true },
    select = {
        enable = true,
        keymaps = {
            ["al"] = "@loop.outer",
            ["il"] = "@loop.inner",
            ["ab"] = "@block.outer",
            ["ib"] = "@block.inner",
            ["ac"] = "@class.outer",
            ["ic"] = "@class.inner",
            ["af"] = "@function.outer",
            ["if"] = "@function.inner",
            ["ap"] = "@parameter.outer",
            ["ip"] = "@parameter.inner",
            ["ak"] = "@comment.outer"
        },
    },
    swap = {
        enable = true,
        swap_next = {
            ["<Leader>cs"] = "@parameter.inner",
        },
        swap_previous = {
            ["<Leader>cs"] = "@parameter.inner",
        },
    },
    move = {
        enable = true,
        set_jumps = true,
        goto_next_start = { ["]]"] = "@function.outer" },
        goto_next_end = { ["]}"] = "@function.outer" },
        goto_previous_start = { ["[["] = "@function.outer" },
        goto_previous_end = { ["[{"] = "@function.outer" },
    }
}
-- ...

vim-commentary can comment out functions and classes, but not uncomment them

I assume this is a bug in this extension rather than vim-commentary, but I don't know that. Please close if it is not.

Commenting in and out code is a PERFECT use of this extension, I hope it can be made to work.

Describe the bug
Using https://github.com/tpope/vim-commentary I can comment out a class or a function with gcac gcaf but when I repeat the command it does not uncomment it. This is the expected behaviour of vim-commentary.

To Reproduce
Try it with vim-commentary on any TypeScript file.

Output of :checkhealth nvim_treesitter

health#nvim_treesitter#check

Installation

  • WARNING: tree-sitter executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
  • OK: node found v14.16.0 (only needed for :TSInstallFromGrammar)
  • OK: git executable found.
  • OK: cc executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl" }
  • OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI.

Parser/Features H L F I J

  • lua βœ“ βœ“ βœ“ βœ“ βœ“
  • json βœ“ βœ“ βœ“ βœ“ .
  • bash βœ“ βœ“ βœ“ . βœ“
  • jsonc βœ“ βœ“ βœ“ βœ“ βœ“
  • rust βœ“ βœ“ βœ“ βœ“ βœ“
  • css βœ“ . βœ“ βœ“ βœ“
  • javascript βœ“ βœ“ βœ“ βœ“ βœ“
  • html βœ“ βœ“ βœ“ βœ“ βœ“
  • typescript βœ“ βœ“ βœ“ βœ“ βœ“
  • c βœ“ βœ“ βœ“ βœ“ βœ“

Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
+) multiple parsers found, only one will be used
x) errors found in the query, try to run :TSUpdate {lang}

Paste the output here

Output of nvim --version

NVIM v0.5.0
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compiled by runner@fv-az242-526

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/home/runner/work/neovim/neovim/build/nvim.AppDir/usr/share/nvim"

Run :checkhealth for more info

Update README workflow should create a PR

Due to branch protection rules it can not directly push to master anymore.

Possible solutions:

  • create an automated PR in that workflow
  • create an exception somehow for Github bot in the branch protection rules

How to set the multiple target?

In scss syntax, the property's value could be multiple.
In treesitter, these values are same level.

For example below, the animation property has 5 value,
But in fact they all belong to one value.
Is there a way to select all the children below declaration, like plain_value, integer_value
but except property_name

ζˆͺ屏2021-05-10 δΈ‹εˆ11 33 15

Support textobjects defined by start and end node

#12

We could define texobjects like in #12 with by their start and end nodes. E.g.:

(
  (method_signature) @function.outer.start
  (function_body) @function.outer.end
) 

or in Lua

(local_function . (_) . (_) . (_) @function.inner.start  (_) @function.inner.end .)

Captures dont work with +/* quantifiers.

I want to create a custom textobject for c and cpp which will select all the statements inside function body excluding function parenthesis. I have added the below query search to textobjects.scm, but nvim-treesitter query seach does not work as expected. I am facing similar issue with nvim-treesitter/playground as well.

(function_definition
  body:  (compound_statement
              ("{" (_)* @function.inner . "}"))?) @function.outer

Steps to reproduce the behavior:

  1. Create a file foo.c
  2. Paste the following contents in foo.c
int foo(int x) {
  int a = 3;
  int b = 4;
  return x + 1;
}
  1. Install nvim-treesitter/playground
  2. In the query editor paste the following
(function_definition
  body:  (compound_statement
              ("{" (_)* @function.inner . "}"))?) @function.outer

@function.inner incorrectly highlights only the last statement inside function parenthesis.

ss

whereas @function.inner should highlight all the statements inside parenthesis.

image

Output of :checkhealth nvim_treesitter

health#nvim_treesitter#check

Installation

  • OK: tree-sitter found 0.20.0 (parser generator, only needed for :TSInstallFromGrammar)
  • OK: node found v16.6.1 (only needed for :TSInstallFromGrammar)
  • OK: git executable found.
  • OK: cc executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl" }
  • OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI.

Parser/Features H L F I J

  • ocaml_interfaceβœ“ βœ“ βœ“ . βœ“
  • beancount βœ“ . βœ“ . .
  • python βœ“ βœ“ βœ“ βœ“ βœ“
  • sparql βœ“ βœ“ βœ“ βœ“ βœ“
  • comment βœ“ . . . .
  • lua βœ“ βœ“ βœ“ βœ“ βœ“
  • ocaml βœ“ βœ“ βœ“ . βœ“
  • go βœ“ βœ“ βœ“ βœ“ βœ“
  • ql βœ“ βœ“ . βœ“ βœ“
  • json βœ“ βœ“ βœ“ βœ“ .
  • jsdoc βœ“ . . . .
  • ledger βœ“ . βœ“ βœ“ βœ“
  • php βœ“ βœ“ βœ“ βœ“ βœ“
  • clojure βœ“ βœ“ βœ“ . βœ“
  • supercollider βœ“ βœ“ βœ“ βœ“ βœ“
  • heex βœ“ . βœ“ βœ“ βœ“
  • typescript βœ“ βœ“ βœ“ βœ“ βœ“
  • fennel βœ“ βœ“ . . βœ“
  • query βœ“ βœ“ βœ“ βœ“ βœ“
  • cpp βœ“ βœ“ βœ“ βœ“ βœ“
  • vue βœ“ . βœ“ . βœ“
  • latex βœ“ . βœ“ . βœ“
  • rst βœ“ βœ“ . . βœ“
  • css βœ“ . βœ“ βœ“ βœ“
  • glimmer βœ“ . . . .
  • erlang . . . . .
  • regex βœ“ . . . .
  • svelte βœ“ . βœ“ βœ“ βœ“
  • c βœ“ βœ“ βœ“ βœ“ βœ“
  • fortran βœ“ . βœ“ βœ“ .
  • teal βœ“ βœ“ βœ“ βœ“ βœ“
  • java βœ“ βœ“ . βœ“ βœ“
  • gomod βœ“ . . . .
  • dart βœ“ βœ“ . βœ“ βœ“
  • verilog βœ“ βœ“ βœ“ . βœ“
  • bash βœ“ βœ“ βœ“ . βœ“
  • yaml βœ“ βœ“ βœ“ βœ“ βœ“
  • julia βœ“ βœ“ βœ“ βœ“ βœ“
  • vim βœ“ . . . βœ“
  • cmake βœ“ . βœ“ . .
  • turtle βœ“ βœ“ βœ“ βœ“ βœ“
  • zig βœ“ . βœ“ βœ“ βœ“
  • html βœ“ βœ“ βœ“ βœ“ βœ“
  • bibtex βœ“ . βœ“ βœ“ .
  • r βœ“ βœ“ . . .
  • tsx βœ“ βœ“ βœ“ βœ“ βœ“
  • yang βœ“ . βœ“ . .
  • javascript βœ“ βœ“ βœ“ βœ“ βœ“
  • surface βœ“ . βœ“ βœ“ βœ“
  • godotResource βœ“ βœ“ βœ“ . .
  • c_sharp βœ“ βœ“ βœ“ . βœ“
  • commonlisp βœ“ βœ“ βœ“ . .
  • gdscript βœ“ βœ“ . . βœ“
  • elixir βœ“ βœ“ βœ“ βœ“ βœ“
  • cuda βœ“ βœ“ βœ“ βœ“ βœ“
  • haskell βœ“ . . . βœ“
  • ocamllex βœ“ . . . βœ“
  • kotlin βœ“ . . . βœ“
  • ruby βœ“ βœ“ βœ“ βœ“ βœ“
  • fish βœ“ βœ“ βœ“ βœ“ βœ“
  • devicetree βœ“ βœ“ βœ“ βœ“ βœ“
  • scala . . . . .
  • dockerfile βœ“ . . . βœ“
  • rust βœ“ βœ“ βœ“ βœ“ βœ“
  • swift . . . . .
  • toml βœ“ βœ“ βœ“ βœ“ βœ“
  • tlaplus βœ“ . βœ“ . βœ“
  • elm . . . . .
  • jsonc βœ“ βœ“ βœ“ βœ“ βœ“
  • graphql βœ“ . . βœ“ βœ“
  • nix βœ“ βœ“ βœ“ . βœ“
  • scss βœ“ . . βœ“ .
  • hcl βœ“ . βœ“ βœ“ βœ“

Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
+) multiple parsers found, only one will be used
x) errors found in the query, try to run :TSUpdate {lang}

Output of nvim --version

NVIM v0.5.0
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=1
-DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/build/neovim/src/neovim-0.5.0/build/config -I/build/neovim/src/neovim-0.5.0/src -I/usr/include -I/build/neovim/src/neovim-0.5.0/build/src/nvim/auto -I/build/neovim/src/neovim-0.5.0/build/include
Compiled by builduser

Features: +acl +iconv +tui
See ":help feature-compile"

system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

I have also tested this on neovim nightly 0.6.0+dev+43+g02bf251bb-1. I am facing the same issue.

Autojump to @inner from @outer

In Vim, when you type a motion outside a textobj, it will auto jump forward then do the motion.
This is super usefull, mean you don't need to move the cursor to the textobj part.

ezgif-3-e88f11e678b7

In treesitter-textobjects, it only do the motion when cursor in right position.

For example below, the @inner is inside @outer.
When do the motion like ca, da, ya. It works good.
Cause cursor always in @outer

But the @inner part, have to move cursor it, then do the motion right.

ζˆͺ屏2021-06-29 上午1 28 10

And here's the config, but I think has nothing to do with the config.

; import
(import_statement
  (import_clause
    [(named_imports) (identifier)] @import.inner)) @import.outer

Add string textobject

Is your feature request related to a problem? Please describe.
I would like to be able to have string textobjects so I can e.g. replace the content of a string with my clipboard

Describe the solution you'd like
@string.outer that includes the quotes and @string.inner that doesn't include the quotes

Describe alternatives you've considered
N/A

Additional context
N/A

Heading or trailing comment in Python class/function not included in text object

Describe the bug

If the first or last element of a Python class or function is a comment, then targeting it as a text object (with @class.outer, @function.inner, etc.) won't include the comment.

This isn't a real problem for me, just a curious edge case I noticed. If fixing this over-complicates other parts of the code or parser, feel free to disregard this and close, but on the off-chance there is a simple fix I'm missing, I thought I would be reporting it.

To Reproduce

With

treesitter.setup {
  textobjects = {
    select = {
      enable = true,
      keymaps = {
        ["ac"] = "@class.outer",
      },
    },
  },
}

and the Python snippet

class A:
    x = 1
    y = 2  # some comment

with the cursor anywhere on or before the character 2, then typing vac will select everything except the comment. If the cursor is on the comment, then typing vac won't do anything.

Expected behavior

With the cursor anywhere in the class, typing vac selects the whole class.

Output of :checkhealth nvim_treesitter

health#nvim_treesitter#check

Installation

  • OK: git executable found.
  • OK: cc executable found.

elm parser healthcheck

c parser healthcheck

  • OK: c parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: textobjects.scm found.
  • OK: folds.scm found.

java parser healthcheck

python parser healthcheck

  • OK: python parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: textobjects.scm found.
  • OK: folds.scm found.

dart parser healthcheck

lua parser healthcheck

  • OK: lua parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: textobjects.scm found.
  • OK: folds.scm found.

ocaml parser healthcheck

go parser healthcheck

nix parser healthcheck

yaml parser healthcheck

json parser healthcheck

jsdoc parser healthcheck

markdown parser healthcheck

julia parser healthcheck

html parser healthcheck

typescript parser healthcheck

  • OK: typescript parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: textobjects.scm found.
  • OK: folds.scm found.

fennel parser healthcheck

swift parser healthcheck

query parser healthcheck

cpp parser healthcheck

  • OK: cpp parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: textobjects.scm found.
  • OK: folds.scm found.

regex parser healthcheck

ruby parser healthcheck

vue parser healthcheck

ql parser healthcheck

scala parser healthcheck

toml parser healthcheck

rust parser healthcheck

bash parser healthcheck

ocaml_interface parser healthcheck

rst parser healthcheck

css parser healthcheck

c_sharp parser healthcheck

javascript parser healthcheck

  • OK: javascript parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: textobjects.scm found.
  • OK: folds.scm found.

php parser healthcheck

haskell parser healthcheck

tsx parser healthcheck

  • OK: tsx parser found.
  • OK: highlights.scm found.
  • OK: locals.scm found.
  • OK: textobjects.scm found.
  • OK: folds.scm found.

Output of nvim --version

NVIM v0.5.0-721-g3c5141d2c
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-5 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/travis/build/neovim/bot-ci/build/neovim/build/config -I/home/travis/build/neovim/bot-ci/build/neovim/src -I/home/travis/build/neovim/bot-ci/build/neovim/.deps/usr/include -I/usr/include -I/home/travis/build/neovim/bot-ci/build/neovim/build/src/nvim/auto -I/home/travis/build/neovim/bot-ci/build/neovim/build/include
Compiled by travis@travis-job-5482189d-7ef7-4d79-892c-6d7ec9adbd1f

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/home/travis/build/neovim/bot-ci/build/neovim/build/nvim.AppDir/usr/share/nvim
"

Run :checkhealth for more info

Pasting a copied parameter before/after the current parameter

I think it would be so useful to use something like this:

require'nvim-treesitter.configs'.setup {
  textobjects = {
    select = {
     enable = true,
      keymaps = {
        ["ap"] = "@parameter.outer", 
      }
    }    
  }
}

nmap <leader>P :TSPasteParameterBefore<CR>
nmap <leader>p :TSPasteParameterAfter<CR>

Then if I could take a function call like:

blah(arg1, arg2, arg3);

and hover arg2 and use dap to delete arg2.

Then hover arg1 and use a keybinding to paste the parameter I just copied before arg1 or use a different keybinding to paste the parameter after arg1 (in this case <leader>P for "before" and <leader>p for "after").

When I do dap it copies the preceding , (or sometimes the trailing ,). When pasting the code would first need to remove the preceding/trailing , and then enter a new , after the pasted parameter when pasting before the final parameter, or enter a preceding , when pasting into the final parameter position. If there are no parameters then no trailing/preceding , would be added (for languages that support trailing , after the last parameter, could leave it up to the user's code formatter to handle this but in cases where a trailing , already exists then pasting into the final parameter position should not enter the preceding ,). I'm aware there are languages that don't use , between parameters such as Haskell, for such languages it would be easier.

This might not be the direction you see nvim-treesitter-textobjects going, and if not, I'm happy to provide this support in a new plugin, but I'd be really grateful for any advice you could give me on how I might implement this.

Treatment of whitespace is inconsistent/inconvenient

Consider a python snippet like the following with the cursor placed at the caret:

print( "a" , "b" , "c" )
            ^

If you try to select parameter.inner or parameter.outer, nothing will happen.

If the cursor is in a different location:

print( "a" , "b" , "c" )
                ^

Now parameter.outer will select something (the "b" parameter up to its comma, but not its leading space),
but parameter.inner still does nothing.

This is probably technically correct according to the way the syntax tree maps to tokens, but it's not very convenient for editing. You'll get similar behavior if you happen to be in whitespace for other text objects, e.g.:

def foo(bar):
    print(bar)
  ^

Here function.outer will select the entire function and body as expected, but function.inner selects nothing.

When the cursor is on whitespace, it should probably "snap" to the next non-whitespace token before looking for the surrounding text object.

After selecting outer, allow an inner select to go back instead of jump ahead

In ruby you have blocks that can look like the following:

foo.each do |item|
  item
end

foo.each { |item| item }

@block.outer in the first case would cover do..end including the do and end and would cover the brackets and everything inside the brackets in the second. (Note in the second example the brackets dont have to be on the same line)

If you were to do a visual selection of the outer and then cancel, your cursor would be moved to the very end of the block(makes sense since this is how other text objects work like word). Your cursor would be on the d in end in the first example and } in the second.

If you then went to select @block.inner you jump to the next instance rather than doing the inner of the outer your cursor is on

If this isnt possible, feel free to close. Appreciate your work on this project!

Screen.Recording.2021-10-02.at.9.57.08.PM.mov

.

"Move" commands not functioning properly for python methods within a class

Describe the bug
When trying to navigate a Python file using the goto_next_start action, @function.outer jumps to the next class definition rather than to the next method within a class

To Reproduce

  1. Config:
require'nvim-treesitter.configs'.setup {
  ensure_installed = "maintained",
  textobjects = {
    move = {
      enable = true,
      keymaps = {
        goto_next_start = {
          ["]]"] = "@function.outer"
        },
      },
    },
  },
}
  1. Example python module
# my_module.py
import os

class MyModuleClass:
    """My module"""
    def method_1(self):
        ...

    def method_2(self):
        ...

class MySecondModuleClass:
    ...
  1. With the cursor on the 'i' in import in normal mode, enter the keymap ]]
  2. Cursor lands on the 'c' in class MyModuleClass
  3. Enter keymap ]] again
  4. Cursor lands at the 'c' in class MySecondModuleClass
  5. Enter keymap ]] again
  6. Cursor lands at bottom of class MySecondModuleClass definition (...)

If the cursor is anywhere within MyModuleClass, entering ]] also moves the cursor to MySecondModuleClass

Expected behavior
Given 1-3 from above remain the same:
4. Cursor lands on the 'd' in def method_1(self)
5. Enter keymap ]] again
6. Cursor lands on the 'd' in def method_2(self)

Output of :checkhealth nvim_treesitter

health#nvim_treesitter#check

Installation

  • OK: tree-sitter found 0.20.0 (parser generator, only needed for :TSInstallFromGrammar)
  • OK: node found v12.22.3 (only needed for :TSInstallFromGrammar)
  • OK: git executable found.
  • OK: cc executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl" }
  • OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI.

Parser/Features H L F I J

  • javascript βœ“ βœ“ βœ“ βœ“ βœ“
  • ocaml βœ“ βœ“ βœ“ . βœ“
  • ocaml_interfaceβœ“ βœ“ βœ“ . βœ“
  • ocamllex βœ“ . . . βœ“
  • c_sharp βœ“ . βœ“ . βœ“
  • vue βœ“ . βœ“ . βœ“
  • yaml βœ“ βœ“ βœ“ βœ“ βœ“
  • html βœ“ βœ“ βœ“ βœ“ βœ“
  • lua βœ“ βœ“ βœ“ βœ“ βœ“
  • tsx βœ“ βœ“ βœ“ βœ“ βœ“
  • css βœ“ . βœ“ βœ“ βœ“
  • supercollider βœ“ βœ“ βœ“ βœ“ βœ“
  • hcl βœ“ . βœ“ . βœ“
  • c βœ“ βœ“ βœ“ βœ“ βœ“
  • toml βœ“ βœ“ βœ“ βœ“ βœ“
  • glimmer βœ“ . . . .
  • jsonc βœ“ βœ“ βœ“ βœ“ βœ“
  • yang βœ“ . βœ“ . .
  • nix βœ“ βœ“ βœ“ . βœ“
  • dart βœ“ βœ“ . βœ“ βœ“
  • rst βœ“ βœ“ . . βœ“
  • fennel βœ“ βœ“ . . βœ“
  • teal βœ“ βœ“ βœ“ βœ“ βœ“
  • typescript βœ“ βœ“ βœ“ βœ“ βœ“
  • clojure βœ“ βœ“ βœ“ . βœ“
  • regex βœ“ . . . .
  • commonlisp βœ“ βœ“ βœ“ . .
  • cpp βœ“ βœ“ βœ“ βœ“ βœ“
  • comment βœ“ . . . .
  • cuda βœ“ βœ“ βœ“ βœ“ βœ“
  • dockerfile βœ“ . . . βœ“
  • sparql βœ“ βœ“ βœ“ βœ“ βœ“
  • rust βœ“ βœ“ βœ“ βœ“ βœ“
  • ledger βœ“ . βœ“ βœ“ βœ“
  • r βœ“ βœ“ . . .
  • python βœ“ βœ“ βœ“ βœ“ βœ“
  • devicetree βœ“ βœ“ βœ“ βœ“ βœ“
  • gomod βœ“ . . . .
  • svelte βœ“ . βœ“ βœ“ βœ“
  • ruby βœ“ βœ“ βœ“ βœ“ βœ“
  • beancount βœ“ . βœ“ . .
  • bash βœ“ βœ“ βœ“ . βœ“
  • latex βœ“ . βœ“ . βœ“
  • fish βœ“ βœ“ βœ“ βœ“ βœ“
  • php βœ“ βœ“ βœ“ βœ“ βœ“
  • java βœ“ βœ“ . βœ“ βœ“
  • kotlin βœ“ . . . βœ“
  • cmake βœ“ . βœ“ . .
  • zig βœ“ βœ“ βœ“ βœ“ βœ“
  • bibtex βœ“ . βœ“ βœ“ .
  • julia βœ“ βœ“ βœ“ βœ“ βœ“
  • json βœ“ βœ“ βœ“ βœ“ .
  • turtle βœ“ βœ“ βœ“ βœ“ βœ“
  • go βœ“ βœ“ βœ“ βœ“ βœ“
  • jsdoc βœ“ . . . .
  • scss βœ“ . . βœ“ .
  • ql βœ“ βœ“ . βœ“ βœ“
  • verilog βœ“ βœ“ βœ“ . βœ“
  • erlang . . . . .
  • query βœ“ βœ“ βœ“ βœ“ βœ“
  • gdscript βœ“ βœ“ . . βœ“
  • elixir βœ“ βœ“ βœ“ βœ“ βœ“
  • graphql βœ“ . . βœ“ βœ“

Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
+) multiple parsers found, only one will be used
x) errors found in the query, try to run :TSUpdate {lang}

Output of nvim --version

NVIM v0.5.0
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: gcc-5 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/tmp/neovim-20210704-5099-1dv0lhc/neovim-0.5.0/build/config -I/tmp/neovim-20210704-5099-1dv0lhc/neovim-0.5.0/src -I/home/linuxbrew/.linuxbrew/include -I/usr/include -I/tmp/neovim-20210704-5099-1dv0lhc/neovim-0.5.0/build/src/nvim/auto -I/tmp/neovim-20210704-5099-1dv0lhc/neovim-0.5.0/build/include
Compiled by linuxbrew@e4b9819dd4f3

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "home/linuxbrew/.linuxbrew/Cellar/neovim/0.5.0/share/nvim"
Run :checkhealth for more info

Swap doesn't repeat with . operator

If I have a piece of code f(a, b, c, d) and I put my cursor on a and perform swap_next for @parameter.inner, it does not compose with .; after the initial swap I have f(b, a, c, d) with the cursor still on a, and I would expect that . would once more do another swap (leaving f(b, c, a, d)). Instead . ignores the swap does whatever happened before that (eg an insertion).

Thanks for this plugin, by the way; enabling this kind of thing is to me one of the most exciting outcomes of treesitter.

Text objects don't work inside of injected languages

Describe the bug

Text objects don't work inside of injected languages.

Pressing daa here doesn't do anything.
image

Related to #27

To Reproduce
Steps to reproduce the behavior using the following textobjects config:

textobjects = {
  select = {
    enable = true,
    lookahead = true,
    keymaps = {
      ["aa"] = "@parameter.outer",
      ["ia"] = "@parameter.inner",
    },
  },
},
  1. Open a new buffer
  2. Type :set ft=vim
  3. Insert this code and move your cursor to the 2nd parameter:
lua <<EOF
test(1, 2)
EOF
  1. Press daa (nothing happens)

Output of :checkhealth nvim_treesitter

nvim_treesitter: health#nvim_treesitter#check
========================================================================
## Installation
  - WARNING: `tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
  - OK: `node` found v16.10.0 (only needed for :TSInstallFromGrammar)
  - OK: `git` executable found.
  - OK: `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
    Version: cc (Debian 8.3.0-6) 8.3.0
  - OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI.

## Parser/Features H L F I J
  - dart           βœ“ βœ“ . βœ“ βœ“ 
  - ruby           βœ“ βœ“ βœ“ βœ“ βœ“ 
  - ocaml_interfaceβœ“ βœ“ βœ“ . βœ“ 
  - c_sharp        βœ“ βœ“ βœ“ . βœ“ 
  - dockerfile     βœ“ . . . βœ“ 
  - svelte         βœ“ . βœ“ βœ“ βœ“ 
  - typescript     βœ“ βœ“ βœ“ βœ“ βœ“ 
  - regex          βœ“ . . . . 
  - zig            βœ“ . βœ“ βœ“ βœ“ 
  - supercollider  βœ“ βœ“ βœ“ βœ“ βœ“ 
  - r              βœ“ βœ“ . . . 
  - haskell        βœ“ . . . βœ“ 
  - hcl            βœ“ . βœ“ βœ“ βœ“ 
  - tlaplus        βœ“ . βœ“ . βœ“ 
  - pioasm         βœ“ . . . βœ“ 
  - glimmer        βœ“ . . . . 
  - json           βœ“ βœ“ βœ“ βœ“ . 
  - fish           βœ“ βœ“ βœ“ βœ“ βœ“ 
  - llvm           βœ“ . . . . 
  - jsonc          βœ“ βœ“ βœ“ βœ“ βœ“ 
  - query          βœ“ βœ“ βœ“ βœ“ βœ“ 
  - yang           βœ“ . βœ“ . . 
  - scala          βœ“ . βœ“ . βœ“ 
  - scss           βœ“ . . βœ“ . 
  - rst            βœ“ βœ“ . . βœ“ 
  - fennel         βœ“ βœ“ . . βœ“ 
  - ql             βœ“ βœ“ . βœ“ βœ“ 
  - heex           βœ“ . βœ“ βœ“ βœ“ 
  - verilog        βœ“ βœ“ βœ“ . βœ“ 
  - c              βœ“ βœ“ βœ“ βœ“ βœ“ 
  - jsdoc          βœ“ . . . . 
  - sparql         βœ“ βœ“ βœ“ βœ“ βœ“ 
  - html           βœ“ βœ“ βœ“ βœ“ βœ“ 
  - toml           βœ“ βœ“ βœ“ βœ“ βœ“ 
  - javascript     βœ“ βœ“ βœ“ βœ“ βœ“ 
  - tsx            βœ“ βœ“ βœ“ βœ“ βœ“ 
  - java           βœ“ βœ“ . βœ“ βœ“ 
  - turtle         βœ“ βœ“ βœ“ βœ“ βœ“ 
  - vue            βœ“ . βœ“ . βœ“ 
  - hjson          βœ“ βœ“ βœ“ βœ“ βœ“ 
  - python         βœ“ βœ“ βœ“ βœ“ βœ“ 
  - lua            βœ“ βœ“ βœ“ βœ“ βœ“ 
  - clojure        βœ“ βœ“ βœ“ . βœ“ 
  - perl           βœ“ . . . . 
  - vim            βœ“ βœ“ . . βœ“ 
  - commonlisp     βœ“ βœ“ βœ“ . . 
  - cmake          βœ“ . βœ“ . . 
  - latex          βœ“ . βœ“ . βœ“ 
  - yaml           βœ“ βœ“ βœ“ βœ“ βœ“ 
  - cuda           βœ“ βœ“ βœ“ βœ“ βœ“ 
  - beancount      βœ“ . βœ“ . . 
  - bibtex         βœ“ . βœ“ βœ“ . 
  - kotlin         βœ“ . . . βœ“ 
  - comment        βœ“ . . . . 
  - glsl           βœ“ βœ“ βœ“ βœ“ βœ“ 
  - fortran        βœ“ . βœ“ βœ“ . 
  - julia          βœ“ βœ“ βœ“ βœ“ βœ“ 
  - graphql        βœ“ . . βœ“ βœ“ 
  - elm            . . . . . 
  - dot            βœ“ . . . βœ“ 
  - json5          βœ“ . . . βœ“ 
  - nix            βœ“ βœ“ βœ“ . βœ“ 
  - rust           βœ“ βœ“ βœ“ βœ“ βœ“ 
  - erlang         . . . . . 
  - ledger         βœ“ . βœ“ βœ“ βœ“ 
  - css            βœ“ . βœ“ βœ“ βœ“ 
  - elixir         βœ“ βœ“ βœ“ βœ“ βœ“ 
  - go             βœ“ βœ“ βœ“ βœ“ βœ“ 
  - php            βœ“ βœ“ βœ“ βœ“ βœ“ 
  - surface        βœ“ . βœ“ βœ“ βœ“ 
  - bash           βœ“ βœ“ βœ“ . βœ“ 
  - gomod          βœ“ . . . . 
  - cpp            βœ“ βœ“ βœ“ βœ“ βœ“ 
  - ocaml          βœ“ βœ“ βœ“ . βœ“ 

  Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
         +) multiple parsers found, only one will be used
         x) errors found in the query, try to run :TSUpdate {lang}

Output of nvim --version

NVIM v0.6.0-dev+479-g9086938f7
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compiled by runner@fv-az50-41

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/home/runner/work/neovim/neovim/build/nvim.AppDir/usr/share/nvim"

Run :checkhealth for more info

How to target the object and include the before text?

For example, in jsx, the each attribute of element are split by <space>.
But Treesitter doesn't include the separator(space).

ζˆͺ屏2021-06-17 δΈ‹εˆ8 44 57

When I delete this textobj(test={true}), the `' before is still there.
This is correct, but it is inconvenient.

ζˆͺ屏2021-06-17 δΈ‹εˆ8 47 39

Then I need to delete that space manually.

图片

So, is there any to target the attribute, but also include the space(one or more) before?

and here's my config now.

; jsx attributes
(jsx_self_closing_element attribute: (_) @attribute.outer)
(jsx_element open_tag: (_ attribute: (_) @attribute.outer))

Can't install the plugin

Describe the bug
I use Neovim nightly (0.6.0)
I can't install the plugin with packer.

To Reproduce
inside my startup function from packer I have:

local use = require('packer').use
require('packer').startup(function()
    -- Package manager
    use 'wbthomason/packer.nvim'

    -- Libs lua
    use({
        'nvim-lua/plenary.nvim',
        'nvim-lua/popup.nvim',
    })

    -- Treesitter
    use({
        'nvim-treesitter/nvim-treesitter',
        config = [[ require('modules.plugins.treesitter') ]],
        requires = {
            'nvim-treesitter/nvim-treesitter-textobjects'
        },
        run = ':TSUpdate',
    })

    -- Lsp
    use({
        'neovim/nvim-lspconfig',
        -- 'ray-x/lsp_signature.nvim',
        'jose-elias-alvarez/nvim-lsp-ts-utils',
        'jose-elias-alvarez/null-ls.nvim',
        requires = {
            'nvim-lua/plenary.nvim',
            'neovim/nvim-lspconfig',
        },
    })

    -- Completion
    use({
        'hrsh7th/nvim-cmp',
        'hrsh7th/cmp-nvim-lsp',
        'hrsh7th/cmp-buffer',
        'hrsh7th/cmp-path',
        'hrsh7th/cmp-nvim-lua',
        'lukas-reineke/cmp-rg',
    })

    -- File explorer
    use({
        'kyazdani42/nvim-tree.lua',
        requires = 'kyazdani42/nvim-web-devicons',
        config = [[ require('modules.plugins.nvimtree') ]],
    })

    -- Dev tools
    use({
        'editorconfig/editorconfig-vim',
    })

    use 'windwp/nvim-autopairs'

    use({
        'norcalli/nvim-colorizer.lua',
        config = [[require('modules.plugins.colorizer')]],
    })

    use 'tpope/vim-commentary' -- "gc" to comment visual regions/lines

    -- Telescope
    use { 'nvim-telescope/telescope.nvim', requires = { 'nvim-lua/plenary.nvim', 'nvim-lua/popup.nvim' } }
    use 'nvim-telescope/telescope-fzf-native.nvim'

    -- Theme
    use({
        'Mofiqul/dracula.nvim',
        'marko-cerovac/material.nvim',
        'kyazdani42/nvim-web-devicons',
    })

    -- Statusline
    use({
        'nvim-lualine/lualine.nvim',
        requires = {
            'nvim-web-devicons',
        },
    })

    use 'arkav/lualine-lsp-progress' -- Integration with progress notifications

    -- i3 support
    use({
        'mboughaba/i3config.vim',
        config = function() require('i3config').setup() end
    })
end)

I have the following error when I try to install it with packer:
nvim-treesitter/nvim-treesitter-textobjects: failed to install

Expected behavior
nvim-treesitter-textobjects should be installed.

Output of nvim --version

NVIM v0.6.0-dev+600-gf71be1f87
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
CompilΓ© par runner@fv-az121-63

Features: +acl +iconv +tui
See ":help feature-compile"

         fichier vimrc système : "$VIM/sysinit.vim"
               $VIM par dΓ©faut : "/share/nvim"

Run :checkhealth for more info

Accept counts

Would be nice if the move commands could accept counts. And also the select commands could accept counts to select an outer textobject in a nested structure.

option to choose/disable textobjects-move module adding to jumplist

Is your feature request related to a problem? Please describe.
I'm always frustrated when [not a problem exactly, but when textobject/move adds to jumplist.]

Describe the solution you'd like
I would like to just move away to my hearts content around the code and not worry about populating the jumplist with [email protected], etc..

Additional context
Textobjects/move is a great feature. it makes navigating through code so much more intuitive, especially in large pages. But I would like to keep the jumplist separate so I can navigate back only to places where I have some edits instead of revisiting random "inspection" jumps from the past. It would make the move module even more necessary and good to use.

Goes without saying, thanks for this plugin, for me personally this and playground are the most important tree-sitter modules to be!

Define @parameter.outer which would include punctuation

First of all, thanks for this plugin! I'm trying it out and the results are impressive!

One thing I'm missing from targets.vim is the "an argument" text object:

Select an argument in a list of arguments. Includes a separator if preset, but excludes surrounding braces. This leaves a proper argument list after deletion. Accepts a count.

      ...........
a , b ( cccccccc , d ) e
        └─── aa β”€β”€β”˜

As I understand the analogue could be @parameter.outer. Unfortunately I wasn't able to see how that could be defined with queries at the moment as the most grammars I've checked do not keep punctuation in the AST. Maybe some out of band solution might work where there's some post processing on the query result to find the matching comma...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.