aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorStephan Seitz <stephan.seitz@fau.de>2022-01-29 21:52:29 +0100
committerStephan Seitz <stephan.seitz@fau.de>2022-01-29 23:45:32 +0100
commit7049a66b54b59a9ff1d32193040e5dcdd9a441d5 (patch)
tree4bd8f5874d5f1670622a43db73a3ba68f0683648 /lua
parentUpdate README (#2399) (diff)
downloadnvim-treesitter-7049a66b54b59a9ff1d32193040e5dcdd9a441d5.tar
nvim-treesitter-7049a66b54b59a9ff1d32193040e5dcdd9a441d5.tar.gz
nvim-treesitter-7049a66b54b59a9ff1d32193040e5dcdd9a441d5.tar.bz2
nvim-treesitter-7049a66b54b59a9ff1d32193040e5dcdd9a441d5.tar.lz
nvim-treesitter-7049a66b54b59a9ff1d32193040e5dcdd9a441d5.tar.xz
nvim-treesitter-7049a66b54b59a9ff1d32193040e5dcdd9a441d5.tar.zst
nvim-treesitter-7049a66b54b59a9ff1d32193040e5dcdd9a441d5.zip
health: check which file caused an error
Diffstat (limited to 'lua')
-rw-r--r--lua/nvim-treesitter/health.lua20
1 files changed, 19 insertions, 1 deletions
diff --git a/lua/nvim-treesitter/health.lua b/lua/nvim-treesitter/health.lua
index b26a9ef25..8cbe0db1c 100644
--- a/lua/nvim-treesitter/health.lua
+++ b/lua/nvim-treesitter/health.lua
@@ -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