Update init.lua

This commit is contained in:
DarthMooMancer
2025-03-05 09:15:48 -05:00
parent 0bdc8841dc
commit f687c94c9a
+7 -6
View File
@@ -22,11 +22,6 @@ M.config = {
}
function M.setup(opts)
-- Clear previous keybindings before setting new ones
for key, _ in pairs(M.config.keybinds) do
vim.keymap.del("n", key)
end
-- 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)
@@ -35,6 +30,13 @@ function M.setup(opts)
-- 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)
end
end
-- Apply keybindings dynamically
for key, command in pairs(M.config.keybinds) do
if command == "CloseTerminal" then
@@ -51,7 +53,6 @@ function M.setup(opts)
vim.api.nvim_create_user_command("JavaRun", M.run, {})
end
-- function M.setup(opts)
-- M.config = vim.tbl_deep_extend("force", M.config, opts or {})
--