From 4fbf150a1621d52f17b099506e1a32f107079210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maria=20Jos=C3=A9=20Solano?= Date: Fri, 2 Feb 2024 13:15:27 -0800 Subject: [PATCH] fix(inc-selection): handle deleting non-existing keymaps --- lua/nvim-treesitter/incremental_selection.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/nvim-treesitter/incremental_selection.lua b/lua/nvim-treesitter/incremental_selection.lua index f6f8fb266..78f0915c8 100644 --- a/lua/nvim-treesitter/incremental_selection.lua +++ b/lua/nvim-treesitter/incremental_selection.lua @@ -155,10 +155,10 @@ function M.detach(bufnr) local config = configs.get_module "incremental_selection" for f, mapping in pairs(config.keymaps) do if mapping then - if f == "init_selection" then - vim.keymap.del("n", mapping, { buffer = bufnr }) - else - vim.keymap.del("x", mapping, { buffer = bufnr }) + local mode = f == "init_selection" and "n" or "x" + local ok, err = pcall(vim.keymap.del, mode, mapping, { buffer = bufnr }) + if not ok then + utils.notify(string.format('%s "%s" for mode %s', err, mapping, mode), vim.log.levels.ERROR) end end end