Skip to content

Commit

Permalink
fix: support overwrite when merge config. (#1394)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayamir authored Jan 17, 2025
1 parent e2f689e commit 7056741
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lua/modules/configs/ui/edgy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,5 @@ return function()
filter = trouble_filter("right"),
},
},
})
}, false, nil, true)
end
9 changes: 7 additions & 2 deletions lua/modules/utils/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ end
---@param opts nil|table @The default config to be merged with
---@param vim_plugin? boolean @If this plugin is written in vimscript or not
---@param setup_callback? function @Add new callback if the plugin needs unusual setup function
function M.load_plugin(plugin_name, opts, vim_plugin, setup_callback)
---@param overwrite? boolean @If load user table-type config by overwriting
function M.load_plugin(plugin_name, opts, vim_plugin, setup_callback, overwrite)
vim_plugin = vim_plugin or false

-- Get the file name of the default config
Expand Down Expand Up @@ -330,7 +331,11 @@ function M.load_plugin(plugin_name, opts, vim_plugin, setup_callback)
if ok then
-- Extend base config if the returned user config is a table
if type(user_config) == "table" then
opts = tbl_recursive_merge(opts, user_config)
if overwrite == true then
opts = vim.tbl_deep_extend("force", opts, user_config)
else
opts = tbl_recursive_merge(opts, user_config)
end
setup_callback(opts)
-- Replace base config if the returned user config is a function
elseif type(user_config) == "function" then
Expand Down

0 comments on commit 7056741

Please sign in to comment.