fix(checkhealth): use pcall to check for syntax errors in query files

This commit is contained in:
Stephan Seitz 2020-09-19 17:05:46 +02:00 committed by Stephan Seitz
parent b3a1ae3210
commit 8c10b1a14d

View file

@ -34,7 +34,13 @@ local function install_health()
end
local function query_health(lang, query_group)
if not queries.get_query(lang, query_group) then
local ok, found_query = pcall(queries.get_query, lang, query_group)
if not ok then
health_error("Error in `"..query_group..".scm` query found for "..lang..'\n'..found_query, {
"Try `:TSUpdate "..lang.."` (queries might have been adapted for a upstream parser change)",
"Try to find the syntax error/invalid node type in above file."
})
elseif not found_query then
health_warn("No `"..query_group..".scm` query found for " .. lang, {
"Open an issue at https://github.com/nvim-treesitter/nvim-treesitter"
})