diff --git a/lua/nvim-tree/view.lua b/lua/nvim-tree/view.lua index 810ebe4c..1e5fb3d2 100644 --- a/lua/nvim-tree/view.lua +++ b/lua/nvim-tree/view.lua @@ -112,6 +112,11 @@ function M._wipe_rogue_buffer() end end +local function warn_wrong_mapping() + local warn_str = "Wrong configuration for keymaps, refer to the new documentation. Keymaps setup aborted" + require'nvim-tree.utils'.echo_warning(warn_str) +end + -- set user options and create tree buffer (should never be wiped) function M.setup() M.View.side = vim.g.nvim_tree_side or M.View.side @@ -137,14 +142,20 @@ function M.setup() if vim.g.nvim_tree_disable_default_keybindings == 1 then M.View.bindings = user_mappings else - M.View.bindings = vim.fn.extend(M.View.bindings, user_mappings) + ok, result = pcall(vim.fn.extend, M.View.bindings, user_mappings) + if not ok then + -- TODO: remove this in a few weeks + warn_wrong_mapping() + return + else + M.View.bindings = result + end end for _, b in pairs(M.View.bindings) do -- TODO: remove this in a few weeks if type(b) == "string" then - local warn_str = "Wrong configuration for keymaps, refer to the new documentation. User keymaps setup aborted" - require'nvim-tree.utils'.echo_warning(warn_str) + warn_wrong_mapping() break end if type(b.key) == "table" then