feat: Invalidate matchup query cache on query save

This commit is contained in:
Dmytro Soltys
2025-04-22 14:14:54 +02:00
committed by Andy K. Massimino
parent 0aa22bc724
commit 6193440b8a

View File

@@ -417,7 +417,32 @@ function! s:treesitter_init_module() " {{{1
if !matchup#loader#_treesitter_may_be_supported()
return
endif
" TODO: do something?
lua <<LUA
vim.api.nvim_create_autocmd({'FileType'}, {
pattern = {'query'},
group = vim.api.nvim_create_augroup('matchup_filetype_query', {
clear = true
}),
callback = function(ftevent)
vim.api.nvim_create_autocmd({'BufWritePost'}, {
buffer = ftevent.buf,
group = vim.api.nvim_create_augroup('MatchupTreesitter', {
clear = true
}),
callback = function(bwpevent)
local _, _, query_lang = string.find(bwpevent.file, "([^/]*)/matchup.scm$")
if query_lang then
vim.treesitter.query.get:clear(
query_lang,
"matchup"
)
end
end
})
end
})
LUA
endfunction
"}}}1