Update init.lua
This commit is contained in:
@@ -22,11 +22,6 @@ M.config = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function M.setup(opts)
|
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
|
-- Merge configs, replacing keybinds table completely if new one is provided
|
||||||
if opts and opts.keybinds then
|
if opts and opts.keybinds then
|
||||||
M.config.keybinds = vim.tbl_extend("force", M.config.keybinds, opts.keybinds)
|
M.config.keybinds = vim.tbl_extend("force", M.config.keybinds, opts.keybinds)
|
||||||
@@ -35,6 +30,13 @@ function M.setup(opts)
|
|||||||
-- Merge other config settings
|
-- Merge other config settings
|
||||||
M.config = vim.tbl_deep_extend("force", M.config, opts or {})
|
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
|
-- 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
|
||||||
@@ -51,7 +53,6 @@ function M.setup(opts)
|
|||||||
vim.api.nvim_create_user_command("JavaRun", M.run, {})
|
vim.api.nvim_create_user_command("JavaRun", M.run, {})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- function M.setup(opts)
|
-- function M.setup(opts)
|
||||||
-- M.config = vim.tbl_deep_extend("force", M.config, opts or {})
|
-- M.config = vim.tbl_deep_extend("force", M.config, opts or {})
|
||||||
--
|
--
|
||||||
|
|||||||
Reference in New Issue
Block a user