diff --git a/lua/nvim-treesitter/configs.lua b/lua/nvim-treesitter/configs.lua index e64dc28e4..6be0c0148 100644 --- a/lua/nvim-treesitter/configs.lua +++ b/lua/nvim-treesitter/configs.lua @@ -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