mirror of
https://github.com/neovim/neovim.git
synced 2025-12-15 19:05:40 +00:00
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:
@@ -186,4 +186,15 @@ function M.inspect(lang)
|
||||
return vim._ts_inspect_language(lang)
|
||||
end
|
||||
|
||||
--- Returns available treesitter languages.
|
||||
function M._complete()
|
||||
local parsers = vim.api.nvim_get_runtime_file('parser/*', true)
|
||||
local parser_names_set = {} ---@type table<string, boolean>
|
||||
for _, parser in ipairs(parsers) do
|
||||
local parser_name = vim.fn.fnamemodify(parser, ':t:r')
|
||||
parser_names_set[parser_name] = true
|
||||
end
|
||||
return vim.tbl_keys(parser_names_set)
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user