nvim-treesitter-textobjects icon indicating copy to clipboard operation
nvim-treesitter-textobjects copied to clipboard

"move" key mapping doesn't work

Open xtrats opened this issue 2 years ago • 5 comments

I changed the key mapping of goto_next_start and goto_previous_start, but it doesn't work. ]m and [m is still the key to jump between functions where I want ]] and [[.

require 'nvim-treesitter.configs'.setup {
  textobjects = {
    move = {
      enable = true,
      set_jumps = true, -- whether to set jumps in the jumplist
      goto_next_start = {
        ["]]"] = "@function.outer",
        ["]m"] = "@class.outer",
      },
      goto_previous_start = {
        ["[["] = "@function.outer",
        ["[m"] = "@class.outer",
      },
    },
  },
}

--

output of nvim --version:

NVIM v0.7.0-dev+914-g7717f38d3
Build type: Debug
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -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/data/download/neovim/build/config -I/data/download/neovim/src -I/data/download/neovim/.deps/usr/include -I/usr/include -I/data/download/neovim/build/src/nvim/auto -I/data/download/neovim/build/include

Features: +acl +iconv +tui

xtrats avatar Jan 28 '22 06:01 xtrats

Hi, what file are you using to test this?

stsewd avatar Jan 29 '22 22:01 stsewd

Also, you can check the output of

:map [[
:map ]]

to verify if the mappings are set

stsewd avatar Jan 29 '22 22:01 stsewd

I'm trying to move to the next parameter, apparently it's not working.

  1. Press v
  2. Press pi => @parameter.inner
  3. Press ]]

https://user-images.githubusercontent.com/16160544/152068893-8e43da43-f83e-430b-a07d-58effa80b1a1.mp4

My config:

move = {
    enable = true,
    set_jumps = true, -- whether to set jumps in the jumplist
    goto_next_start = {
      [']m'] = '@function.outer',
      [']]'] = '@parameter.inner',
    },
    goto_next_end = {
      [']M'] = '@function.outer',
      [']['] = '@class.outer',
    },
    goto_previous_start = {
      ['[m'] = '@function.outer',
      ['[['] = '@class.outer',
    },
    goto_previous_end = {
      ['[M'] = '@function.outer',
      ['[]'] = '@class.outer',
    },
  },

aspeddro avatar Feb 01 '22 23:02 aspeddro

I rebuilt my configure files from scratch, and I think I found the reason. When I removed the ray-x/go.nvim plugin, the "move" mapping works. When I reinstall the ray-x/go.nvim plugin, the mapping doesn't work again, even when I want to move in .cpp files. So I think there is something in the ray-x/go.nvim stop "move" mapping from working.

xtrats avatar Feb 15 '22 11:02 xtrats

setup ray-x/go.nvim before treesitter works for me

edolphin-ydf avatar Apr 22 '22 08:04 edolphin-ydf

Closing as completed.

kiyoon avatar Jan 05 '23 19:01 kiyoon