mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-18 11:20:07 -04:00
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:
parent
5948aba886
commit
08f1a8561f
1 changed files with 8 additions and 7 deletions
|
|
@ -151,7 +151,9 @@ local function enable_mod_conf_autocmd(mod, lang)
|
||||||
end
|
end
|
||||||
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)
|
local config_mod = M.get_module(mod)
|
||||||
|
|
||||||
if not config_mod then return end
|
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
|
for _, bufnr in pairs(api.nvim_list_bufs()) do
|
||||||
local ft = api.nvim_buf_get_option(bufnr, 'ft')
|
local ft = api.nvim_buf_get_option(bufnr, 'ft')
|
||||||
if not lang or parsers.lang_match_ft(lang, ft) then
|
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
|
||||||
end
|
end
|
||||||
if lang then
|
if lang then
|
||||||
|
|
@ -168,7 +172,7 @@ local function enable_all(mod, lang)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
for _, lang in pairs(parsers.available_parsers()) do
|
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)
|
enable_mod_conf_autocmd(mod, lang)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -306,12 +310,9 @@ function M.setup(user_data)
|
||||||
|
|
||||||
recurse_modules(function(_, _, new_path)
|
recurse_modules(function(_, _, new_path)
|
||||||
if data.enable then
|
if data.enable then
|
||||||
enable_all(new_path)
|
enable_all(new_path, nil, data.disable)
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, lang in ipairs(data.disable or {}) do
|
|
||||||
disable_mod_conf_autocmd(new_path, lang)
|
|
||||||
end
|
|
||||||
end, config.modules)
|
end, config.modules)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue