refactor(nvim): use builtin table merge function
This commit is contained in:
parent
07e1294937
commit
e154f827fd
1 changed files with 1 additions and 29 deletions
|
@ -69,34 +69,6 @@ vim.api.nvim_create_autocmd("InsertEnter", {
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
---merge tables
|
|
||||||
---@param ... table[]
|
|
||||||
---@return table
|
|
||||||
local function table_merge(...)
|
|
||||||
local tables_to_merge = { ... }
|
|
||||||
assert(#tables_to_merge > 1, "There should be at least two tables to merge them")
|
|
||||||
|
|
||||||
for k, t in ipairs(tables_to_merge) do
|
|
||||||
assert(type(t) == "table", string.format("Expected a table as function parameter %d", k))
|
|
||||||
end
|
|
||||||
|
|
||||||
local result = tables_to_merge[1]
|
|
||||||
|
|
||||||
for i = 2, #tables_to_merge do
|
|
||||||
local from = tables_to_merge[i]
|
|
||||||
for k, v in pairs(from) do
|
|
||||||
if type(v) == "table" then
|
|
||||||
result[k] = result[k] or {}
|
|
||||||
result[k] = table_merge(result[k], v)
|
|
||||||
else
|
|
||||||
result[k] = v
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return result
|
|
||||||
end
|
|
||||||
|
|
||||||
local lsp_lines = require("lsp_lines")
|
local lsp_lines = require("lsp_lines")
|
||||||
lsp_lines.setup()
|
lsp_lines.setup()
|
||||||
-- Disable virtual_text since it's redundant due to lsp_lines.
|
-- Disable virtual_text since it's redundant due to lsp_lines.
|
||||||
|
@ -222,7 +194,7 @@ local lspconfig_default_options = {
|
||||||
---@param options table
|
---@param options table
|
||||||
---@return nil
|
---@return nil
|
||||||
local function lspconfig_setup(lsp, options)
|
local function lspconfig_setup(lsp, options)
|
||||||
local final_options = table_merge(lspconfig_default_options, options)
|
local final_options = vim.tbl_deep_extend("force", lspconfig_default_options, options)
|
||||||
lspconfig[lsp].setup(final_options)
|
lspconfig[lsp].setup(final_options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue