diff options
| author | patrick96 <p.ziegler96@gmail.com> | 2021-11-20 22:31:22 +0100 |
|---|---|---|
| committer | Stephan Seitz <stephan.seitz@fau.de> | 2021-11-28 00:31:02 +0100 |
| commit | d24a1c63d4057e858d47e4594c8899cbf1536121 (patch) | |
| tree | c502a5ccf4c02e03540b17d94c69e0e89cb48a06 /lua | |
| parent | Rename cond to condition (diff) | |
| download | nvim-treesitter-d24a1c63d4057e858d47e4594c8899cbf1536121.tar nvim-treesitter-d24a1c63d4057e858d47e4594c8899cbf1536121.tar.gz nvim-treesitter-d24a1c63d4057e858d47e4594c8899cbf1536121.tar.bz2 nvim-treesitter-d24a1c63d4057e858d47e4594c8899cbf1536121.tar.lz nvim-treesitter-d24a1c63d4057e858d47e4594c8899cbf1536121.tar.xz nvim-treesitter-d24a1c63d4057e858d47e4594c8899cbf1536121.tar.zst nvim-treesitter-d24a1c63d4057e858d47e4594c8899cbf1536121.zip | |
Make disable accept a function
Replaces the condition setting (though it does the exact inverse)
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/nvim-treesitter/configs.lua | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/lua/nvim-treesitter/configs.lua b/lua/nvim-treesitter/configs.lua index 9f563af59..3da54fd7e 100644 --- a/lua/nvim-treesitter/configs.lua +++ b/lua/nvim-treesitter/configs.lua @@ -23,15 +23,16 @@ local builtin_modules = { highlight = { module_path = "nvim-treesitter.highlight", enable = false, - disable = { "markdown" }, -- FIXME(vigoux): markdown highlighting breaks everything for now custom_captures = {}, - is_supported = queries.has_highlights, + is_supported = function(lang) + -- FIXME(vigoux): markdown highlighting breaks everything for now + return lang ~= "markdown" and queries.has_highlights(lang) + end, additional_vim_regex_highlighting = false, }, incremental_selection = { module_path = "nvim-treesitter.incremental_selection", enable = false, - disable = {}, keymaps = { init_selection = "gnn", node_incremental = "grn", @@ -45,7 +46,6 @@ local builtin_modules = { indent = { module_path = "nvim-treesitter.indent", enable = false, - disable = {}, is_supported = queries.has_indents, }, } @@ -351,16 +351,21 @@ function M.is_enabled(mod, lang, bufnr) return false end - if module_config.condition and not module_config.condition(lang, bufnr) then - return false - end - - for _, parser in pairs(module_config.disable) do - if lang == parser then + local disable = module_config.disable + if type(disable) == 'function' then + if disable(lang, bufnr) then return false end + elseif type(disable) == 'table' then + -- Otherwise it's a list of languages + for _, parser in pairs(disable) do + if lang == parser then + return false + end + end end + return true end |
