From 8c10b1a14d158cb5c81fdc5ab0507451b5f465a4 Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Sat, 19 Sep 2020 17:05:46 +0200 Subject: fix(checkhealth): use pcall to check for syntax errors in query files --- lua/nvim-treesitter/health.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/nvim-treesitter/health.lua b/lua/nvim-treesitter/health.lua index c5f59274..923314f5 100644 --- a/lua/nvim-treesitter/health.lua +++ b/lua/nvim-treesitter/health.lua @@ -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" }) -- cgit v1.2.3