From 52a133876d738abd0d68161c780d31996e671eae Mon Sep 17 00:00:00 2001 From: DarthMooMancer <107283522+DarthMooMancer@users.noreply.github.com> Date: Wed, 5 Mar 2025 09:40:12 -0500 Subject: [PATCH] Update init.lua --- lua/Javanvim/init.lua | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lua/Javanvim/init.lua b/lua/Javanvim/init.lua index 03be232..37dc5ed 100644 --- a/lua/Javanvim/init.lua +++ b/lua/Javanvim/init.lua @@ -22,21 +22,19 @@ M.config = { } function M.setup(opts) - -- Merge configs, replacing keybinds table completely if new one is provided - if opts and opts.keybinds then - M.config.keybinds = vim.tbl_extend("force", M.config.keybinds, opts.keybinds) - end - - -- Merge other config settings - M.config = vim.tbl_deep_extend("force", M.config, opts or {}) - - -- 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) + opts = opts or {} + -- Apply default keybinds if not defined by user + if opts.keybinds then + for key, command in pairs(M.config.keybinds) do + if not opts.keybinds[key] then + opts.keybinds[key] = command + end end end + -- Merge the configurations + M.config = vim.tbl_deep_extend("force", M.config, opts) + -- Apply keybindings dynamically for key, command in pairs(M.config.keybinds) do if command == "CloseTerminal" then