feat(config): add global disable option

This commit is contained in:
Stephan Seitz 2020-08-22 23:32:35 +02:00
parent 627a1e558f
commit c3e6369db6
3 changed files with 10 additions and 3 deletions

View file

@ -83,6 +83,7 @@ so you'll need to activate them by putting this in your `init.vim` file:
lua <<EOF
require'nvim-treesitter.configs'.setup {
ensure_installed = "all" -- one of "all", "language", or a list of languages
disable = {"markdown"}, -- a list of languages to disable for all modules (only enable manually)
highlight = {
enable = true, -- false will disable the whole extension
disable = { "c", "rust" }, -- list of language that will be disabled

View file

@ -37,6 +37,7 @@ To enable supported features, put this in your `init.vim` file:
lua <<EOF
require'nvim-treesitter.configs'.setup {
ensure_installed = "all" -- one of "all", "language", or a list of languages
disable = {"markdown"}, -- a list of languages to disable for all modules (only enable manually)
highlight = {
enable = true, -- false will disable the whole extension
disable = { "c", "rust" }, -- list of language that will be disabled

View file

@ -300,17 +300,22 @@ function M.setup(user_data)
config.ensure_installed = data
require'nvim-treesitter.install'.ensure_installed(data)
else
data.disable = data.disable or {}
for _, lang in ipairs(user_data.disable or {}) do
if not vim.tbl_contains(data.disable, lang) then
table.insert(data.disable, lang)
end
end
config.modules[name] = vim.tbl_deep_extend('force', config.modules[name] or {}, data)
recurse_modules(function(_, _, new_path)
if data.enable then
enable_all(new_path)
end
for _, lang in ipairs(data.disable or {}) do
for _, lang in ipairs(config.modules[name].disable) do
disable_mod_conf_autocmd(new_path, lang)
end
end, config.modules)
end, config.modules[name])
end
end
end