diff options
| author | Steven Sojka <steelsojka@gmail.com> | 2020-07-15 08:47:16 -0500 |
|---|---|---|
| committer | Thomas Vigouroux <39092278+vigoux@users.noreply.github.com> | 2020-07-15 15:54:10 +0200 |
| commit | ec2f4df1d8dad52d41a457513821907024c631b5 (patch) | |
| tree | 59ec67052d279654c31c4765074b90ba07f41536 /lua | |
| parent | feat(refactor.navigation): update jumplist on jump (diff) | |
| download | nvim-treesitter-ec2f4df1d8dad52d41a457513821907024c631b5.tar nvim-treesitter-ec2f4df1d8dad52d41a457513821907024c631b5.tar.gz nvim-treesitter-ec2f4df1d8dad52d41a457513821907024c631b5.tar.bz2 nvim-treesitter-ec2f4df1d8dad52d41a457513821907024c631b5.tar.lz nvim-treesitter-ec2f4df1d8dad52d41a457513821907024c631b5.tar.xz nvim-treesitter-ec2f4df1d8dad52d41a457513821907024c631b5.tar.zst nvim-treesitter-ec2f4df1d8dad52d41a457513821907024c631b5.zip | |
fix(configs): deep merge table configs
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/nvim-treesitter/configs.lua | 42 |
1 files changed, 5 insertions, 37 deletions
diff --git a/lua/nvim-treesitter/configs.lua b/lua/nvim-treesitter/configs.lua index 6a094b39b..38a78d943 100644 --- a/lua/nvim-treesitter/configs.lua +++ b/lua/nvim-treesitter/configs.lua @@ -89,8 +89,6 @@ local builtin_modules = { } } -local special_config_keys = {'enable', 'disable', 'keymaps'} - -- Resolves a module by requiring the `module_path` or using the module definition. local function resolve_module(mod_name) local config_mod = M.get_module(mod_name) @@ -279,41 +277,11 @@ end -- @param user_data module overrides function M.setup(user_data) for name, data in pairs(user_data) do - local mod = config.modules[name] or {} - M.setup_module(mod, data, name) - config.modules[name] = mod - end -end - --- Sets up a single module or all submodules of a group. --- Note, this method is recursive. --- @param mod the module or group of modules --- @param data user defined configuration for the module --- @param mod_name name of the module if it exists -function M.setup_module(mod, data, mod_name) - if mod_name == 'ensure_installed' then - config.ensure_installed = data - require'nvim-treesitter.install'.ensure_installed(data) - elseif M.is_module(mod) and type(data) == 'table' then - if type(data.enable) == 'boolean' then - mod.enable = data.enable - end - if type(data.disable) == 'table' then - mod.disable = data.disable - end - if mod.keymaps and type(data.keymaps) == 'table' then - mod.keymaps = vim.tbl_extend("force", mod.keymaps, data.keymaps) - end - - for k, v in pairs(data) do - -- Just copy all non-special configuration keys - if not vim.tbl_contains(special_config_keys, k) then - mod[k] = v - end - end - elseif type(data) == 'table' and type(mod) == 'table' then - for key, value in pairs(mod) do - M.setup_module(value, data[key], key) + if name == 'ensure_installed' then + config.ensure_installed = data + require'nvim-treesitter.install'.ensure_installed(data) + else + config.modules[name] = vim.tbl_deep_extend('force', config.modules[name] or {}, data) end end end |
