From 3a6dddd489c41736bc10a35e53f02dec6466d6aa Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Sun, 28 Mar 2021 02:00:11 -0700 Subject: Remove duplicated tbl_deep_extend --- lua/lspconfig/configs.lua | 8 ++++---- lua/lspconfig/util.lua | 34 ---------------------------------- 2 files changed, 4 insertions(+), 38 deletions(-) (limited to 'lua') diff --git a/lua/lspconfig/configs.lua b/lua/lspconfig/configs.lua index 13b92b17..b0642bf6 100644 --- a/lua/lspconfig/configs.lua +++ b/lua/lspconfig/configs.lua @@ -97,10 +97,10 @@ function configs.__newindex(t, config_name, config_def) end local make_config = function(_root_dir) - local new_config = util.tbl_deep_extend("keep", vim.empty_dict(), config) - new_config = util.tbl_deep_extend('keep', new_config, default_config) + local new_config = vim.tbl_deep_extend("keep", vim.empty_dict(), config) + new_config = vim.tbl_deep_extend('keep', new_config, default_config) new_config.capabilities = new_config.capabilities or lsp.protocol.make_client_capabilities() - new_config.capabilities = util.tbl_deep_extend('keep', new_config.capabilities, { + new_config.capabilities = vim.tbl_deep_extend('keep', new_config.capabilities, { workspace = { configuration = true; } @@ -188,7 +188,7 @@ function configs.__newindex(t, config_name, config_def) client.config._on_attach(client, bufnr) end if client.config.commands and not vim.tbl_isempty(client.config.commands) then - M.commands = util.tbl_deep_extend("force", M.commands, client.config.commands) + M.commands = vim.tbl_deep_extend("force", M.commands, client.config.commands) end if not M.commands_created and not vim.tbl_isempty(M.commands) then -- Create the module commands diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua index a6dabd78..dca330ae 100644 --- a/lua/lspconfig/util.lua +++ b/lua/lspconfig/util.lua @@ -46,40 +46,6 @@ function M.add_hook_after(func, new_fn) end end -function M.tbl_deep_extend(behavior, ...) - if (behavior ~= 'error' and behavior ~= 'keep' and behavior ~= 'force') then - error('invalid "behavior": '..tostring(behavior)) - end - - if select('#', ...) < 2 then - error('wrong number of arguments (given '..tostring(1 + select('#', ...))..', expected at least 3)') - end - - local ret = {} - if vim._empty_dict_mt ~= nil and getmetatable(select(1, ...)) == vim._empty_dict_mt then - ret = vim.empty_dict() - end - - for i = 1, select('#', ...) do - local tbl = select(i, ...) - vim.validate{["after the second argument"] = {tbl,'t'}} - if tbl then - for k, v in pairs(tbl) do - if type(v) == 'table' and not vim.tbl_islist(v) then - ret[k] = M.tbl_deep_extend(behavior, ret[k] or vim.empty_dict(), v) - elseif behavior ~= 'force' and ret[k] ~= nil then - if behavior == 'error' then - error('key found in more than one map: '..k) - end -- Else behavior is "keep". - else - ret[k] = v - end - end - end - end - return ret -end - function M.create_module_commands(module_name, commands) for command_name, def in pairs(commands) do local parts = {"command!"} -- cgit v1.2.3-70-g09d2