mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-03 12:06:55 -04:00
health: check which file caused an error
This commit is contained in:
parent
5e3a93f365
commit
7049a66b54
1 changed files with 19 additions and 1 deletions
|
|
@ -142,7 +142,25 @@ function M.check()
|
|||
health_start "The following errors have been detected:"
|
||||
for _, p in ipairs(error_collection) do
|
||||
local lang, type, err = unpack(p)
|
||||
health_error(lang .. "(" .. type .. "): " .. err)
|
||||
local lines = {}
|
||||
table.insert(lines, lang .. "(" .. type .. "): " .. err)
|
||||
local files = vim.treesitter.query.get_query_files(lang, type)
|
||||
if #files > 0 then
|
||||
table.insert(lines, lang .. "(" .. type .. ") is concatenated from the following files:")
|
||||
for _, file in ipairs(files) do
|
||||
local fd = io.open(file, "r")
|
||||
if fd then
|
||||
local ok, file_err = pcall(vim.treesitter.query.parse_query, lang, fd:read "*a")
|
||||
if ok then
|
||||
table.insert(lines, '| [OK]:"' .. file .. '"')
|
||||
else
|
||||
table.insert(lines, '| [ERROR]:"' .. file .. '", failed to load: ' .. file_err)
|
||||
end
|
||||
fd:close()
|
||||
end
|
||||
end
|
||||
end
|
||||
health_error(table.concat(lines, "\n"))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue