Update init.lua
This commit is contained in:
+10
-12
@@ -22,21 +22,19 @@ M.config = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function M.setup(opts)
|
function M.setup(opts)
|
||||||
-- Merge configs, replacing keybinds table completely if new one is provided
|
opts = opts or {}
|
||||||
if opts and opts.keybinds then
|
-- Apply default keybinds if not defined by user
|
||||||
M.config.keybinds = vim.tbl_extend("force", M.config.keybinds, opts.keybinds)
|
if opts.keybinds then
|
||||||
end
|
for key, command in pairs(M.config.keybinds) do
|
||||||
|
if not opts.keybinds[key] then
|
||||||
-- Merge other config settings
|
opts.keybinds[key] = command
|
||||||
M.config = vim.tbl_deep_extend("force", M.config, opts or {})
|
end
|
||||||
|
|
||||||
-- Safely remove existing keybindings before setting new ones
|
|
||||||
for key, _ in pairs(M.config.keybinds) do
|
|
||||||
if pcall(vim.keymap.del, "n", key) then
|
|
||||||
-- Keybinding was successfully deleted (only if it existed)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Merge the configurations
|
||||||
|
M.config = vim.tbl_deep_extend("force", M.config, opts)
|
||||||
|
|
||||||
-- Apply keybindings dynamically
|
-- Apply keybindings dynamically
|
||||||
for key, command in pairs(M.config.keybinds) do
|
for key, command in pairs(M.config.keybinds) do
|
||||||
if command == "CloseTerminal" then
|
if command == "CloseTerminal" then
|
||||||
|
|||||||
Reference in New Issue
Block a user