fix(keymap setup): do not crash on vim.fn.extend to explain the user keymap config has changed
This commit is contained in:
@@ -112,6 +112,11 @@ function M._wipe_rogue_buffer()
|
|||||||
end
|
end
|
||||||
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)
|
-- set user options and create tree buffer (should never be wiped)
|
||||||
function M.setup()
|
function M.setup()
|
||||||
M.View.side = vim.g.nvim_tree_side or M.View.side
|
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
|
if vim.g.nvim_tree_disable_default_keybindings == 1 then
|
||||||
M.View.bindings = user_mappings
|
M.View.bindings = user_mappings
|
||||||
else
|
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
|
end
|
||||||
|
|
||||||
for _, b in pairs(M.View.bindings) do
|
for _, b in pairs(M.View.bindings) do
|
||||||
-- TODO: remove this in a few weeks
|
-- TODO: remove this in a few weeks
|
||||||
if type(b) == "string" then
|
if type(b) == "string" then
|
||||||
local warn_str = "Wrong configuration for keymaps, refer to the new documentation. User keymaps setup aborted"
|
warn_wrong_mapping()
|
||||||
require'nvim-tree.utils'.echo_warning(warn_str)
|
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
if type(b.key) == "table" then
|
if type(b.key) == "table" then
|
||||||
|
|||||||
Reference in New Issue
Block a user