checkhealth for all query groups

This commit is contained in:
Stephan Seitz 2020-07-15 00:38:09 +02:00 committed by Thomas Vigouroux
parent f5f5e3ec51
commit 31d1f068fd
3 changed files with 14 additions and 20 deletions

View file

@ -32,23 +32,13 @@ local function install_health()
end
end
local function highlight_health(lang)
if not queries.get_query(lang, "highlights") then
health_warn("No `highlights.scm` query found for " .. lang, {
local function query_health(lang, query_group)
if not queries.get_query(lang, query_group) then
health_warn("No `"..query_group..".scm` query found for " .. lang, {
"Open an issue at https://github.com/nvim-treesitter/nvim-treesitter"
})
else
health_ok("`highlights.scm` found.")
end
end
local function locals_health(lang)
if not queries.get_query(lang, "locals") then
health_warn("No `locals.scm` query found for " .. lang, {
"Open an issue at https://github.com/nvim-treesitter/nvim-treesitter"
})
else
health_ok("`locals.scm` found.")
health_ok("`"..query_group..".scm` found.")
end
end
@ -67,8 +57,10 @@ function M.checkhealth()
health_start(parser_name .. " parser healthcheck")
health_ok(parser_name .. " parser found.")
locals_health(parser_name)
highlight_health(parser_name)
for _, query_group in pairs(queries.built_in_query_groups) do
query_health(parser_name, query_group)
end
elseif installed > 1 then
health_warn(string.format("Multiple parsers found for %s, only %s will be used.", parser_name, installed[1]))
else

View file

@ -34,9 +34,11 @@ M.query_extensions = {
tsx = {'javascript.jsx'}
}
M.has_locals = get_query_guard('locals')
M.has_textobjects = get_query_guard('textobjects')
M.has_highlights = get_query_guard('highlights')
M.built_in_query_groups = {'highlights', 'locals', 'textobjects'}
for _, query in ipairs(M.built_in_query_groups) do
M["has_" .. query] = get_query_guard(query)
end
function M.get_query(lang, query_name)
local query_files = api.nvim_get_runtime_file(string.format('queries/%s/%s.scm', lang, query_name), true)

View file

@ -2,7 +2,7 @@
local function do_check()
local parsers = require 'nvim-treesitter.parsers'.available_parsers()
local queries = require 'nvim-treesitter.query'
local query_types = {'highlights', 'locals', 'textobjects'}
local query_types = queries.built_in_query_groups
for _, lang in pairs(parsers) do
for _, query_type in pairs(query_types) do