fixup: proper union of tables

This commit is contained in:
Christian Clason 2024-01-18 17:08:20 +01:00
parent 503d0ccdee
commit 5037721ec5

View file

@ -405,6 +405,18 @@ function M.is_enabled(mod, lang, bufnr)
return true
end
---Combine two list-like tables without duplicates
local union = function(x, y)
local map = {}
for _, v in ipairs(x) do
map[v] = true
end
for _, v in ipairs(y) do
map[v] = true
end
return vim.tbl_keys(map)
end
---Setup call for users to override module configurations.
---@param user_data TSConfig module overrides
function M.setup(user_data)
@ -422,7 +434,7 @@ function M.setup(user_data)
local ensure_installed = user_data.ensure_installed or config.ensure_installed
if type(ensure_installed) == "table" and type(config.ensure_installed) == "table" then
vim.list_extend(ensure_installed, config.ensure_installed)
union(ensure_installed, config.ensure_installed)
end
if #ensure_installed > 0 then
if user_data.sync_install then