mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-20 12:20:02 -04:00
checkhealth for all query groups
This commit is contained in:
parent
f5f5e3ec51
commit
31d1f068fd
3 changed files with 14 additions and 20 deletions
|
|
@ -32,23 +32,13 @@ local function install_health()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function highlight_health(lang)
|
local function query_health(lang, query_group)
|
||||||
if not queries.get_query(lang, "highlights") then
|
if not queries.get_query(lang, query_group) then
|
||||||
health_warn("No `highlights.scm` query found for " .. lang, {
|
health_warn("No `"..query_group..".scm` query found for " .. lang, {
|
||||||
"Open an issue at https://github.com/nvim-treesitter/nvim-treesitter"
|
"Open an issue at https://github.com/nvim-treesitter/nvim-treesitter"
|
||||||
})
|
})
|
||||||
else
|
else
|
||||||
health_ok("`highlights.scm` found.")
|
health_ok("`"..query_group..".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.")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -67,8 +57,10 @@ function M.checkhealth()
|
||||||
health_start(parser_name .. " parser healthcheck")
|
health_start(parser_name .. " parser healthcheck")
|
||||||
health_ok(parser_name .. " parser found.")
|
health_ok(parser_name .. " parser found.")
|
||||||
|
|
||||||
locals_health(parser_name)
|
for _, query_group in pairs(queries.built_in_query_groups) do
|
||||||
highlight_health(parser_name)
|
query_health(parser_name, query_group)
|
||||||
|
end
|
||||||
|
|
||||||
elseif installed > 1 then
|
elseif installed > 1 then
|
||||||
health_warn(string.format("Multiple parsers found for %s, only %s will be used.", parser_name, installed[1]))
|
health_warn(string.format("Multiple parsers found for %s, only %s will be used.", parser_name, installed[1]))
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,11 @@ M.query_extensions = {
|
||||||
tsx = {'javascript.jsx'}
|
tsx = {'javascript.jsx'}
|
||||||
}
|
}
|
||||||
|
|
||||||
M.has_locals = get_query_guard('locals')
|
M.built_in_query_groups = {'highlights', 'locals', 'textobjects'}
|
||||||
M.has_textobjects = get_query_guard('textobjects')
|
|
||||||
M.has_highlights = get_query_guard('highlights')
|
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)
|
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)
|
local query_files = api.nvim_get_runtime_file(string.format('queries/%s/%s.scm', lang, query_name), true)
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
local function do_check()
|
local function do_check()
|
||||||
local parsers = require 'nvim-treesitter.parsers'.available_parsers()
|
local parsers = require 'nvim-treesitter.parsers'.available_parsers()
|
||||||
local queries = require 'nvim-treesitter.query'
|
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 _, lang in pairs(parsers) do
|
||||||
for _, query_type in pairs(query_types) do
|
for _, query_type in pairs(query_types) do
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue