Skip parsers in query check that are not installed

This commit is contained in:
Stephan Seitz 2021-03-07 19:31:09 +01:00 committed by Kiyan
parent 4b0ba7781f
commit 28bc7a0703

View file

@ -29,24 +29,28 @@ local function do_check()
local last_error local last_error
for _, lang in pairs(parsers) do for _, lang in pairs(parsers) do
for _, query_type in pairs(query_types) do if parsers.has_parser(lang) then
print('Checking '..lang..' '..query_type) for _, query_type in pairs(query_types) do
local ok, query = pcall(queries.get_query,lang, query_type) print('Checking '..lang..' '..query_type)
if not ok then local ok, query = pcall(queries.get_query,lang, query_type)
vim.api.nvim_err_writeln(query) if not ok then
last_error = query vim.api.nvim_err_writeln(query)
else last_error = query
if query then else
for _, capture in ipairs(query.captures) do if query then
if not vim.startswith(capture, "_") -- We ignore things like _helper for _, capture in ipairs(query.captures) do
and captures[query_type] if not vim.startswith(capture, "_") -- We ignore things like _helper
and not capture:find("^[A-Z]") -- Highlight groups and captures[query_type]
and not vim.tbl_contains(captures[query_type], capture) then and not capture:find("^[A-Z]") -- Highlight groups
error(string.format("Invalid capture @%s in %s for %s.", capture, query_type, lang)) and not vim.tbl_contains(captures[query_type], capture) then
error(string.format("Invalid capture @%s in %s for %s.", capture, query_type, lang))
end
end end
end end
end end
end end
else
print("No parser for "..lang.." installed! Skipping...")
end end
end end
if last_error then if last_error then