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.
This commit is contained in:
Stephan Seitz 2020-08-30 21:06:09 +02:00 committed by Thomas Vigouroux
parent 5948aba886
commit 08f1a8561f

View file

@ -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