From 784bb3c10093b428c4dcc97f113fee8ce501350d Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 12 Jan 2023 13:13:30 +0100 Subject: [PATCH] refactor: removed special `__merge` functionality --- lua/lazy/core/util.lua | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/lua/lazy/core/util.lua b/lua/lazy/core/util.lua index c13d7fe..8a937a8 100644 --- a/lua/lazy/core/util.lua +++ b/lua/lazy/core/util.lua @@ -298,27 +298,10 @@ function M.debug(msg, opts) end end -local MERGE = "__merge" - local function can_merge(v) return type(v) == "table" and (vim.tbl_isempty(v) or not M.is_list(v)) end -local function can_extend(v) - return type(v) == "table" and (vim.tbl_isempty(v) or M.is_list(v)) -end - ----@param v any|{__merge:boolean} ----@param merge? boolean ----@return boolean? -local function check_merge(v, merge) - if type(v) == "table" and v[MERGE] ~= nil then - merge = v[MERGE] - v[MERGE] = nil - end - return merge -end - --- Merges the values similar to vim.tbl_deep_extend with the **force** behavior, --- but the values can be any type, in which case they override the values on the left. --- Values will me merged in-place in the first left-most table. If you want the result to be in @@ -335,19 +318,12 @@ function M.merge(...) ret = nil end - local merge = check_merge(ret) - for i = 2, #values, 1 do local value = values[i] - merge = check_merge(value, merge) - if can_merge(ret) and can_merge(value) and merge ~= false then + if can_merge(ret) and can_merge(value) then for k, v in pairs(value) do ret[k] = M.merge(ret[k], v) end - elseif can_extend(ret) and can_extend(value) and merge then - for _, v in ipairs(value) do - ret[#ret + 1] = v - end elseif value == vim.NIL then ret = nil else