mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
fixup: proper union of tables
This commit is contained in:
parent
503d0ccdee
commit
5037721ec5
1 changed files with 13 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue