nvim-treesitter / nvim-treesitter-textobjects

Apache License 2.0
2.19k stars 196 forks source link

'move' mappings are not created #278

Closed loqusion closed 2 years ago

loqusion commented 2 years ago

Describe the bug

'move' mappings are not created

To Reproduce

Here's my treesitter config. The mappings I made for 'move' don't work, and when I enter :map ]m, etc to check if the mappings are made, it says "No mapping found". However, the 'select' mappings are still made.

  require('nvim-treesitter.configs').setup {
    ensure_installed = 'all',
    ignore_install = { 'php', 'phpdoc' },
    additional_vim_regex_highlighting = false,
    highlight = {
      enable = true,
      disable = {
        'vim',
        'help',
      },
    },
    indent = {
      -- Enabling this removes the leading space from /*...*...*/ comments! This is annoying!!
      enable = false,
    },
    incremental_selection = {
      enable = false,
      keymaps = {
        init_selection = 'gnn',
        scope_incremental = 'gna',
        node_incremental = 'grn',
        node_decremental = 'grm',
      },
    },
    autotag = {
      enable = true,
      filetypes = { 'html', 'javascript', 'javascriptreact', 'typescriptreact', 'svelte', 'vue', 'markdown' },
    },
    context_commentstring = {
      -- https://github.com/JoosepAlviste/nvim-ts-context-commentstring#commentnvim
      enable = true,
      enable_autocmd = false,
    },
    endwise = { enable = true },
    matchup = { enable = true },
    query_linter = {
      enable = true,
      use_virtual_text = true,
      lint_events = { 'BufWrite', 'CursorHold' },
    },
    tree_setter = {
      enable = false,
    },
    textobjects = {
      select = {
        enable = true,
        -- Automatically jump forward to textobj, similar to targets.vim
        lookahead = true,
        keymaps = {
          ['af'] = '@function.outer',
          ['if'] = '@function.inner',
          ['il'] = '@loop.inner',
          ['al'] = '@loop.outer',
          -- ['icd'] = '@conditional.inner',
          -- ['acd'] = '@conditional.outer',
          -- ['acm'] = '@comment.outer',
          ['ast'] = '@statement.outer',
          ['isc'] = '@scopename.inner',
          ['iB'] = '@block.inner',
          ['aB'] = '@block.outer',
          ['ia'] = '@parameter.inner',
          ['aa'] = '@parameter.outer',
        },
      },
      move = {
        enable = true,
        set_jumps = true, -- whether to set jumps in the jumplist
        goto_next_start = {
          [']m'] = '@function.outer',
          [']im'] = '@function.inner',
          [')'] = '@parameter.inner',
          -- [']c'] = '@call.outer',
          -- [']ic'] = '@call.inner',
        },
        goto_next_end = {
          [']M'] = '@function.outer',
          [']iM'] = '@function.inner',
          ['g)'] = '@parameter.inner',
          -- [']C'] = '@call.outer',
          -- [']iC'] = '@call.inner',
        },
        goto_previous_start = {
          ['[m'] = '@function.outer',
          ['[im'] = '@function.inner',
          ['('] = '@parameter.inner',
          -- ['[c'] = '@call.outer',
          -- ['[ic'] = '@call.inner',
        },
        goto_previous_end = {
          ['[M'] = '@function.outer',
          ['[iM'] = '@function.inner',
          ['g('] = '@parameter.inner',
          -- ['[C'] = '@call.outer',
          -- ['[iC'] = '@call.inner',
        },
      },
    },
    textsubjects = {
      enable = true,
      keymaps = {
        ['.'] = 'textsubjects-smart',
      },
    },
  }

Output of :checkhealth nvim-treesitter

nvim-treesitter: require("nvim-treesitter.health").check() ======================================================================== ## Installation - OK: `tree-sitter` found 0.20.6 (parser generator, only needed for :TSInstallFromGrammar) - OK: `node` found v18.8.0 (only needed for :TSInstallFromGrammar) - OK: `git` executable found. - OK: `/usr/bin/clang` executable found. Selected from { "/usr/bin/clang", "cc", "gcc", "clang", "cl", "zig" } Version: Apple clang version 13.1.6 (clang-1316.0.21.2.5) - OK: Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI. ## Parser/Features H L F I J - glsl ✓ ✓ ✓ ✓ ✓ - pascal ✓ ✓ ✓ ✓ ✓ - ruby ✓ ✓ ✓ ✓ ✓ - cuda ✓ ✓ ✓ ✓ ✓ - d ✓ . ✓ ✓ ✓ - cpp ✓ ✓ ✓ ✓ ✓ - ql ✓ ✓ . ✓ ✓ - commonlisp ✓ ✓ ✓ . . - teal ✓ ✓ ✓ ✓ ✓ - sxhkdrc ✓ . ✓ . ✓ - gitignore ✓ . . . . - embedded_template✓ . . . ✓ - tiger ✓ ✓ ✓ ✓ ✓ - m68k ✓ ✓ ✓ . ✓ - rego ✓ . . . ✓ - gomod ✓ . . . ✓ - nix ✓ ✓ ✓ . ✓ - elixir ✓ ✓ ✓ ✓ ✓ - julia ✓ ✓ ✓ ✓ ✓ - kotlin ✓ ✓ ✓ . ✓ - v ✓ ✓ ✓ ✓ ✓ - racket ✓ . ✓ . ✓ - astro ✓ ✓ ✓ ✓ ✓ - qmljs ✓ . ✓ . . - yaml ✓ ✓ ✓ ✓ ✓ - wgsl ✓ . ✓ . . - meson ✓ . ✓ . ✓ - elvish ✓ . . . ✓ - norg . . . . . - agda ✓ . ✓ . . - jsonc ✓ ✓ ✓ ✓ ✓ - solidity ✓ . . . . - lalrpop ✓ ✓ . . . - json ✓ ✓ ✓ ✓ . - comment ✓ . . . . - prisma ✓ . . . . - cooklang ✓ . . . . - vala ✓ . ✓ . . - hack ✓ . . . . - glimmer ✓ . . . . - foam ✓ ✓ ✓ ✓ ✓ - make ✓ . . . ✓ - toml ✓ ✓ ✓ ✓ ✓ - bash ✓ ✓ ✓ . ✓ - rasi ✓ ✓ ✓ ✓ . - rnoweb ✓ . ✓ . ✓ - vim ✓ ✓ ✓ . ✓ - tlaplus ✓ ✓ ✓ . ✓ - cmake ✓ . ✓ . . - lua ✓ ✓ ✓ ✓ ✓ - devicetree ✓ ✓ ✓ ✓ ✓ - latex ✓ . ✓ . ✓ - http ✓ . . . ✓ - markdown_inline✓ . . . ✓ - help ✓ . . . . - llvm ✓ . . . . - typescript ✓ ✓ ✓ ✓ ✓ - hcl ✓ . ✓ ✓ ✓ - hocon ✓ . . . ✓ - fortran ✓ . ✓ ✓ . - haskell ✓ . ✓ . ✓ - hjson ✓ ✓ ✓ ✓ ✓ - bibtex ✓ . ✓ ✓ . - slint ✓ . . ✓ . - pioasm ✓ . . . ✓ - supercollider ✓ ✓ ✓ ✓ ✓ - json5 ✓ . . . ✓ - html ✓ ✓ ✓ ✓ ✓ - javascript ✓ ✓ ✓ ✓ ✓ - scala ✓ . ✓ . ✓ - beancount ✓ . ✓ . . - tsx ✓ ✓ ✓ ✓ ✓ - vue ✓ . ✓ ✓ ✓ - todotxt ✓ . . . . - r ✓ ✓ . ✓ ✓ - rust ✓ ✓ ✓ ✓ ✓ - svelte ✓ . ✓ ✓ ✓ - zig ✓ . ✓ ✓ ✓ - c_sharp ✓ ✓ ✓ . ✓ - turtle ✓ ✓ ✓ ✓ ✓ - query ✓ ✓ ✓ ✓ ✓ - swift ✓ ✓ . . . - ninja ✓ . ✓ ✓ . - markdown ✓ . ✓ . ✓ - elm ✓ . . . ✓ - fish ✓ ✓ ✓ ✓ ✓ - ocamllex ✓ . . . ✓ - org . . . . . - graphql ✓ . . ✓ ✓ - ocaml_interface✓ ✓ ✓ . ✓ - c ✓ ✓ ✓ ✓ ✓ - jsdoc ✓ . . . . - heex ✓ ✓ ✓ ✓ ✓ - fennel ✓ ✓ . . ✓ - eex ✓ . . . ✓ - clojure ✓ ✓ ✓ . ✓ - regex ✓ . . . . - surface ✓ . ✓ ✓ ✓ - verilog ✓ ✓ ✓ . ✓ - gleam ✓ ✓ ✓ ✓ ✓ - gowork ✓ . . . ✓ - rst ✓ ✓ . . ✓ - dart ✓ ✓ . ✓ ✓ - godot_resource ✓ ✓ ✓ . . - erlang ✓ . ✓ . . - yang ✓ . ✓ ✓ . - scss ✓ . . ✓ . - gdscript ✓ ✓ . ✓ ✓ - css ✓ . ✓ ✓ ✓ - pug ✓ . . . ✓ - sql ✓ . . . ✓ - ledger ✓ . ✓ ✓ ✓ - sparql ✓ ✓ ✓ ✓ ✓ - ocaml ✓ ✓ ✓ . ✓ - fusion ✓ ✓ ✓ ✓ . - go ✓ ✓ ✓ ✓ ✓ - perl ✓ . ✓ . . - java ✓ ✓ . ✓ ✓ - dot ✓ . . . ✓ - scheme ✓ . ✓ . ✓ - dockerfile ✓ . . . ✓ - python ✓ ✓ ✓ ✓ ✓ - hlsl ✓ ✓ ✓ ✓ ✓ - proto ✓ . ✓ . . 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.0-dev-977-g92bc11a89-dirty
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by REDACTED

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

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/opt/homebrew/Cellar/neovim/HEAD-92bc11a_1/share/nvim"

Run :checkhealth for more info
NEX-S commented 2 years ago

Seems I got the same ERROR

E5108: Error executing lua: ...ter-textobjects/lua/nvim-treesitter/textobjects/move.lua:53: bad argument #1 to 'ipairs' (table expected, got nil)
stack traceback:
        [C]: in function 'ipairs'
        ...ter-textobjects/lua/nvim-treesitter/textobjects/move.lua:53: in function 'move'
        ...ter-textobjects/lua/nvim-treesitter/textobjects/move.lua:73: in function <...ter-textobjects/lua/nvim-treesitter/textobjects/move.lua:72>
        ...r-textobjects/lua/nvim-treesitter/textobjects/attach.lua:28: in function <...r-textobjects/lua/nvim-treesitter/textobjects/attach.lua:27>
loqusion commented 2 years ago

Can confirm, now the mappings are created for me but I'm getting the same error.

E5108: Error executing lua: ...ter-textobjects/lua/nvim-treesitter/textobjects/move.lua:53: bad argument #1 to 'ipairs' (table expected, got nil)
stack traceback:
        [C]: in function 'ipairs'
        ...ter-textobjects/lua/nvim-treesitter/textobjects/move.lua:53: in function 'move'
        ...ter-textobjects/lua/nvim-treesitter/textobjects/move.lua:73: in function <...ter-textobjects/lua/nvim-treesitter/textobjects/move.lua:72>
        ...r-textobjects/lua/nvim-treesitter/textobjects/attach.lua:28: in function <...r-textobjects/lua/nvim-treesitter/textobjects/attach.lua:27>