fix(treesitter): ":EditQuery [lang]" with injected languages #34914

Problem:
`:EditQuery` command accepts a language argument, but it doesn't
highlight properly for injected languages.

Solution:
- Fully parse with the root language and then filter the query on the
  child trees that are of the language requested.
- Also support completion (`EditQuery <tab>`).
This commit is contained in:
Peter Cardenas
2025-07-19 11:36:51 -07:00
committed by GitHub
parent c5167ffc18
commit e5c2ce5905
5 changed files with 48 additions and 16 deletions

View File

@@ -23,7 +23,13 @@ do
vim.api.nvim_create_user_command('EditQuery', function(cmd)
vim.treesitter.query.edit(cmd.fargs[1])
end, { desc = 'Edit treesitter query', nargs = '?' })
end, {
desc = 'Edit treesitter query',
nargs = '?',
complete = function()
return vim.treesitter.language._complete()
end,
})
vim.api.nvim_create_user_command('Open', function(cmd)
vim.ui.open(assert(cmd.fargs[1]))