mirror of https://github.com/folke/lazy.nvim.git
perf(plugin): de-duplicate dependencies, keys, ft, event and cmd
This commit is contained in:
parent
da4e8cc245
commit
1b2a6f631c
|
@ -287,7 +287,7 @@ function Spec:merge(old, new)
|
|||
end
|
||||
|
||||
if new.dependencies and old.dependencies then
|
||||
vim.list_extend(new.dependencies, old.dependencies)
|
||||
Util.extend(new.dependencies, old.dependencies)
|
||||
end
|
||||
|
||||
new._.super = old
|
||||
|
@ -424,7 +424,7 @@ function M.values(plugin, prop, is_list)
|
|||
end
|
||||
|
||||
values = type(values) == "table" and values or { values }
|
||||
return is_list and vim.list_extend(ret, values) or Util.merge(ret, values)
|
||||
return is_list and Util.extend(ret, values) or Util.merge(ret, values)
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
@ -222,6 +222,23 @@ function M.lsmod(modname, fn)
|
|||
end)
|
||||
end
|
||||
|
||||
---@generic T
|
||||
---@param list T[]
|
||||
---@param add T[]
|
||||
---@return T[]
|
||||
function M.extend(list, add)
|
||||
local idx = {}
|
||||
for _, v in ipairs(list) do
|
||||
idx[v] = v
|
||||
end
|
||||
for _, a in ipairs(add) do
|
||||
if not idx[a] then
|
||||
table.insert(list, a)
|
||||
end
|
||||
end
|
||||
return list
|
||||
end
|
||||
|
||||
---@alias LazyNotifyOpts {lang?:string, title?:string, level?:number}
|
||||
|
||||
---@param msg string|string[]
|
||||
|
|
Loading…
Reference in New Issue