summaryrefslogtreecommitdiff
path: root/lua/nvim-treesitter/configs.lua
diff options
context:
space:
mode:
authorSteven Sojka <Steven.Sojka@tdameritrade.com>2020-06-29 09:58:51 -0500
committerKiyan Yazdani <yazdani.kiyan@protonmail.com>2020-06-30 08:21:01 +0200
commitd73500eaa6b25edf476d73d0d1a47c65043b6e88 (patch)
treee44533f9c8ac12d91f841bc53423fde3d0119939 /lua/nvim-treesitter/configs.lua
parent6f8e4c97a4f99b1a04cca5c41c333ffb5337d84a (diff)
refactor(refactor): use higher local apis and some cleanup
Diffstat (limited to 'lua/nvim-treesitter/configs.lua')
-rw-r--r--lua/nvim-treesitter/configs.lua22
1 files changed, 10 insertions, 12 deletions
diff --git a/lua/nvim-treesitter/configs.lua b/lua/nvim-treesitter/configs.lua
index 1d3e1c75..da80c818 100644
--- a/lua/nvim-treesitter/configs.lua
+++ b/lua/nvim-treesitter/configs.lua
@@ -237,21 +237,19 @@ end
function M.setup(user_data)
if not user_data then return end
- for mod, data in pairs(user_data) do
- if config.modules[mod] then
- M.setup_module(config.modules[mod], data)
- elseif mod == 'ensure_installed' then
- config.ensure_installed = data
- require'nvim-treesitter.install'.ensure_installed(data)
- end
- end
+ M.setup_module(config.modules, user_data)
end
---- Sets up a single module or all submodules of a group
+-- 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
-function M.setup_module(mod, data)
- if M.is_module(mod) then
+-- @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) then
if type(data.enable) == 'boolean' then
mod.enable = data.enable
end
@@ -267,7 +265,7 @@ function M.setup_module(mod, data)
end
elseif type(data) == 'table' and type(mod) == 'table' then
for key, value in pairs(data) do
- M.setup_module(mod[key], value)
+ M.setup_module(mod[key], value, key)
end
end
end