fix(highlight): Use TS built-in is_enabled function (#1513)

The function just replicated the logic from is_enabled and assumed the
`disable` setting is always a table. This is no longer the case
(https://github.com/nvim-treesitter/nvim-treesitter/pull/2009), it can
now also be a function.
This commit is contained in:
Patrick Ziegler
2021-11-30 21:18:08 +01:00
committed by GitHub
parent c9439871ef
commit ce8c8d4a45

View File

@@ -96,11 +96,11 @@ end
local treesitter_attach = function(bufnr, ft)
local lang = ts_parsers.ft_to_lang(ft)
if ts_parsers.has_parser(lang) then
local config = ts_configs.get_module "highlight"
if vim.tbl_contains(config.disable, lang) then
if not ts_configs.is_enabled("highlight", lang, bufnr) then
return false
end
local config = ts_configs.get_module "highlight"
for k, v in pairs(config.custom_captures) do
vim.treesitter.highlighter.hl_map[k] = v
end
@@ -113,8 +113,6 @@ local treesitter_attach = function(bufnr, ft)
vim.api.nvim_buf_set_option(bufnr, "syntax", ft)
end
return true
end
return false
end
-- Attach ts highlighter