nvim-treesitter / nvim-treesitter-textobjects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Calling the `TSTextobjectSelect` command directly inserts a newline instead of selecting a text object

jxcrw opened this issue · comments

Describe the bug
Calling the TSTextobjectSelect command directly inserts a newline instead of selecting a text object.

To Reproduce
After setting up a minimal treesitter-textobjects config:

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",
      },
    },
  },
}

Pressing vaf (starting from normal mode) selects a function, as expected.

However, running :TSTextobjectSelect @function.outer directly on the command line causes a newline to be inserted at the beginning of the function rather than selecting the function.

Similarly, binding a key to this call in my keymap (i.e., vim.keymap.set({'n'}, 'foobar', ':TSTextobjectSelect @function.outer<CR>', {noremap = true})) results in the same behavior - a newline is inserted at the beginning of the function rather than the function being selected.

Expected behavior
Pressing vaf, calling :TSTextobjectSelect @function.outer from the command line, and binding a key to :TSTextobjectSelect @function.outer<CR> should all result in the same behavior - the function should be selected.

Output of :checkhealth nvim-treesitter

nvim-treesitter: require("nvim-treesitter.health").check()

Installation

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

OS Info:

{
machine = "x86_64",
release = "10.0.22621",
sysname = "Windows_NT",
version = "Windows 10 Pro"
}

Parser/Features H L F I J

  • help ✓ . . . ✓
  • lua ✓ ✓ ✓ ✓ ✓
  • markdown ✓ . ✓ . ✓
  • python ✓ ✓ ✓ ✓ ✓
  • rust ✓ ✓ ✓ ✓ ✓

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.8.3
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compiled by runneradmin@fv-az171-224

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

      システム vimrc: "$VIM\sysinit.vim"
       省略時の $VIM: "C:/Program Files (x86)/nvim/share/nvim"

Run :checkhealth for more info

Additional context
I had everything working nicely at some point in the not too distant past. I am unsure whether this is happening due to a recent update to treesitter, treesitter-textobjects, or my own simple boneheadedness. I may very well be doing something silly.

I have also tried:

  • Disabling all other plugins and keymaps. The behavior persists, so I believe I can rule out any kind of strange interaction between plugins/keymaps.
  • Using the latest build of neovim-nightly instead of the latest stable build neovim 0.8.3. The behavior persists, so I believe the issue is not unique to a particular neovim release channel.

Thanks for reporting the issue. It should be fixed now.

Confirmed fixed. Thank you for the patch! ˶ᵔ ᵕ ᵔ˶