mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-18 20:36:45 +00:00
feat(plugin): opts_extend
can be a list of dotted keys that will be extended instead of merged
This commit is contained in:
parent
89ddc59d19
commit
1f7b720cff
2 changed files with 52 additions and 1 deletions
|
@ -667,7 +667,27 @@ function M._values(root, plugin, prop, is_list)
|
|||
end
|
||||
|
||||
values = type(values) == "table" and values or { values }
|
||||
return is_list and Util.extend(ret, values) or Util.merge(ret, values)
|
||||
if is_list then
|
||||
return Util.extend(ret, values)
|
||||
else
|
||||
---@type {path:string[], list:any[]}[]
|
||||
local lists = {}
|
||||
for _, key in ipairs(plugin[prop .. "_extend"] or {}) do
|
||||
local path = vim.split(key, ".", { plain = true })
|
||||
local r = Util.key_get(ret, path)
|
||||
local v = Util.key_get(values, path)
|
||||
if type(r) == "table" and type(v) == "table" then
|
||||
lists[key] = { path = path, list = {} }
|
||||
vim.list_extend(lists[key].list, r)
|
||||
vim.list_extend(lists[key].list, v)
|
||||
end
|
||||
end
|
||||
local t = Util.merge(ret, values)
|
||||
for _, list in pairs(lists) do
|
||||
Util.key_set(t, list.path, list.list)
|
||||
end
|
||||
return t
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue