diff options
| author | Stephan Seitz <stephan.seitz@fau.de> | 2020-08-31 19:04:14 +0200 |
|---|---|---|
| committer | Thomas Vigouroux <39092278+vigoux@users.noreply.github.com> | 2020-08-31 21:34:57 +0200 |
| commit | 6352cdc943f707d3f6db5f0c8ed7820ba02f7ed5 (patch) | |
| tree | 04e3fd1b7fa1a9fd88a0b7e0b92d346166d70cd5 | |
| parent | fix(highlight_current_scope): Ensure that detach is a inverse of attach (diff) | |
| download | nvim-treesitter-6352cdc943f707d3f6db5f0c8ed7820ba02f7ed5.tar nvim-treesitter-6352cdc943f707d3f6db5f0c8ed7820ba02f7ed5.tar.gz nvim-treesitter-6352cdc943f707d3f6db5f0c8ed7820ba02f7ed5.tar.bz2 nvim-treesitter-6352cdc943f707d3f6db5f0c8ed7820ba02f7ed5.tar.lz nvim-treesitter-6352cdc943f707d3f6db5f0c8ed7820ba02f7ed5.tar.xz nvim-treesitter-6352cdc943f707d3f6db5f0c8ed7820ba02f7ed5.tar.zst nvim-treesitter-6352cdc943f707d3f6db5f0c8ed7820ba02f7ed5.zip | |
Fix(modules): simplify configs.setup
This prevents a really weird bug were the following function call (after
loading the activated modules) could activate `highlight_current_scope`
```lua
require "nvim-treesitter.configs".setup(
{
highlight = {
enable = false, -- false will disable the whole extension
disable = {"html", "lua"} -- list of language that will be disabled
},
refactor = {
highlight_current_scope = {
enable = false,
inverse_highlighting = true,
disable = {"python", "markdown"}
},
highlight_definitions = {
enable = true,
disable = {"markdown"}
},
},
ensure_installed = "all",
disable = {"markdown"}, -- list of language that will be disabled
}
)
```
| -rw-r--r-- | lua/nvim-treesitter/configs.lua | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/lua/nvim-treesitter/configs.lua b/lua/nvim-treesitter/configs.lua index c66838d9b..204498e8d 100644 --- a/lua/nvim-treesitter/configs.lua +++ b/lua/nvim-treesitter/configs.lua @@ -161,7 +161,7 @@ local function enable_all(mod, lang, blocklist) 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 - if not vim.tbl_contains(blocklist, lang) then + if not vim.tbl_contains(blocklist, lang or parsers.ft_to_lang(ft)) then enable_module(mod, bufnr, lang) end end @@ -301,21 +301,17 @@ end -- Setup call for users to override module configurations. -- @param user_data module overrides function M.setup(user_data) - for name, data in pairs(user_data) do - if name == 'ensure_installed' then - config.ensure_installed = data - require'nvim-treesitter.install'.ensure_installed(data) - else - config.modules[name] = vim.tbl_deep_extend('force', config.modules[name] or {}, data) + config.modules = vim.tbl_deep_extend('force', config.modules, user_data) - recurse_modules(function(_, _, new_path) - if data.enable then - enable_all(new_path, nil, data.disable) - end + require'nvim-treesitter.install'.ensure_installed(user_data.ensure_installed) + config.modules.ensure_installed = nil - end, config.modules) + recurse_modules(function(_, _, new_path) + local data = utils.get_at_path(config.modules, new_path) + if data.enable then + enable_all(new_path, nil, data.disable) end - end + end, config.modules) end -- Defines a table of modules that can be attached/detached to buffers |
