Handle nested TS syntax, closes #271

This commit is contained in:
Andy K. Massimino
2023-02-18 15:58:45 -05:00
parent d7a5d19354
commit 2dffaedded

View File

@@ -32,7 +32,20 @@ function M.is_hl_enabled(bufnr)
end
function M.get_matches(bufnr)
return queries.get_matches(bufnr, 'matchup')
local parser = parsers.get_parser(bufnr)
local matches = {}
if parser then
parser:for_each_tree(function(tree, lang_tree)
local lang = lang_tree:lang()
local group_results = queries.collect_group_results(
bufnr, 'matchup', tree:root(), lang) or {}
vim.list_extend(matches, group_results)
end)
end
return matches
end
local function _time()
@@ -349,9 +362,6 @@ function M.get_option(bufnr, opt_name)
end
function M.attach(bufnr, lang)
-- local parser = parsers.get_parser(bufnr, lang)
-- local config = configs.get_module('matchup')
if M.get_option(bufnr, 'additional_vim_regex_highlighting')
and api.nvim_buf_get_option(bufnr, 'syntax') == '' then
api.nvim_buf_set_option(bufnr, 'syntax', 'ON')