From 08f1a8561fcaad08930994c594d4f43944d07a26 Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Sun, 30 Aug 2020 21:06:09 +0200 Subject: Avoid enabling disabled modules (even if they were disabled immediately) This might be safer for the case that attach/detach are not inverse to each other. Disabled modules shouldn't ever be activated. --- lua/nvim-treesitter/configs.lua | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'lua') diff --git a/lua/nvim-treesitter/configs.lua b/lua/nvim-treesitter/configs.lua index 5fba72348..c66838d9b 100644 --- a/lua/nvim-treesitter/configs.lua +++ b/lua/nvim-treesitter/configs.lua @@ -151,7 +151,9 @@ local function enable_mod_conf_autocmd(mod, lang) end end -local function enable_all(mod, lang) +local function enable_all(mod, lang, blocklist) + blocklist = blocklist or {} + local config_mod = M.get_module(mod) if not config_mod then return end @@ -159,7 +161,9 @@ local function enable_all(mod, lang) for _, bufnr in pairs(api.nvim_list_bufs()) do local ft = api.nvim_buf_get_option(bufnr, 'ft') if not lang or parsers.lang_match_ft(lang, ft) then - enable_module(mod, bufnr, lang) + if not vim.tbl_contains(blocklist, lang) then + enable_module(mod, bufnr, lang) + end end end if lang then @@ -168,7 +172,7 @@ local function enable_all(mod, lang) end else for _, lang in pairs(parsers.available_parsers()) do - if parsers.has_parser(lang) then + if parsers.has_parser(lang) and not vim.tbl_contains(blocklist, lang) then enable_mod_conf_autocmd(mod, lang) end end @@ -306,12 +310,9 @@ function M.setup(user_data) recurse_modules(function(_, _, new_path) if data.enable then - enable_all(new_path) + enable_all(new_path, nil, data.disable) end - for _, lang in ipairs(data.disable or {}) do - disable_mod_conf_autocmd(new_path, lang) - end end, config.modules) end end -- cgit v1.2.3-70-g09d2