diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua index baf63ef..b7179c9 100644 --- a/lua/lazy/core/plugin.lua +++ b/lua/lazy/core/plugin.lua @@ -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 diff --git a/lua/lazy/core/util.lua b/lua/lazy/core/util.lua index 3a27a8f..9a81d28 100644 --- a/lua/lazy/core/util.lua +++ b/lua/lazy/core/util.lua @@ -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[]