fix: node_incremental for incremental selection jumping around (#3257)

This commit is contained in:
itepechi / いてぺち 2022-08-02 21:40:25 +09:00 committed by GitHub
parent f7ac82c48e
commit abb8b5756a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -131,15 +131,20 @@ function M.attach(bufnr)
local config = configs.get_module "incremental_selection"
for funcname, mapping in pairs(config.keymaps) do
local mode
local rhs
if funcname == "init_selection" then
mode = "n"
rhs = M[funcname]
else
mode = "x"
-- We need to move to command mode to access marks '< (visual area start) and '> (visual area end) which are not
-- properly accessible in visual mode.
rhs = string.format(":lua require'nvim-treesitter.incremental_selection'.%s()<CR>", funcname)
end
vim.keymap.set(
mode,
mapping,
M[funcname],
rhs,
{ buffer = bufnr, silent = true, noremap = true, desc = FUNCTION_DESCRIPTIONS[funcname] }
)
end