diff options
| -rw-r--r-- | lua/nvim-treesitter/health.lua | 24 | ||||
| -rw-r--r-- | lua/nvim-treesitter/query.lua | 8 | ||||
| -rwxr-xr-x | scripts/check-queries.lua | 2 |
3 files changed, 14 insertions, 20 deletions
diff --git a/lua/nvim-treesitter/health.lua b/lua/nvim-treesitter/health.lua index d3083e77b..cfb823c5f 100644 --- a/lua/nvim-treesitter/health.lua +++ b/lua/nvim-treesitter/health.lua @@ -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 diff --git a/lua/nvim-treesitter/query.lua b/lua/nvim-treesitter/query.lua index 7316c79cb..69e52e1e6 100644 --- a/lua/nvim-treesitter/query.lua +++ b/lua/nvim-treesitter/query.lua @@ -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) diff --git a/scripts/check-queries.lua b/scripts/check-queries.lua index 3fff461d3..f7e282c37 100755 --- a/scripts/check-queries.lua +++ b/scripts/check-queries.lua @@ -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 |
