aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lua/nvim-treesitter/incremental_selection.lua21
1 files changed, 7 insertions, 14 deletions
diff --git a/lua/nvim-treesitter/incremental_selection.lua b/lua/nvim-treesitter/incremental_selection.lua
index 0ba10971e..f6f8fb266 100644
--- a/lua/nvim-treesitter/incremental_selection.lua
+++ b/lua/nvim-treesitter/incremental_selection.lua
@@ -5,6 +5,7 @@ local ts_utils = require "nvim-treesitter.ts_utils"
local locals = require "nvim-treesitter.locals"
local parsers = require "nvim-treesitter.parsers"
local queries = require "nvim-treesitter.query"
+local utils = require "nvim-treesitter.utils"
local M = {}
@@ -138,22 +139,14 @@ function M.attach(bufnr)
local config = configs.get_module "incremental_selection"
for funcname, mapping in pairs(config.keymaps) do
if mapping then
- ---@type string, string|function
- local mode, rhs
- if funcname == "init_selection" then
- mode = "n"
- ---@type function
- rhs = M[funcname]
+ local mode = funcname == "init_selection" and "n" or "x"
+ local rhs = M[funcname] ---@type function
+
+ if not rhs then
+ utils.notify("Unknown keybinding: " .. funcname .. debug.traceback(), vim.log.levels.ERROR)
else
- mode = "x"
- rhs = M[funcname] ---@type function
+ vim.keymap.set(mode, mapping, rhs, { buffer = bufnr, silent = true, desc = FUNCTION_DESCRIPTIONS[funcname] })
end
- vim.keymap.set(
- mode,
- mapping,
- rhs,
- { buffer = bufnr, silent = true, noremap = true, desc = FUNCTION_DESCRIPTIONS[funcname] }
- )
end
end
end