diff options
| author | Stephan Seitz <stephan.seitz@fau.de> | 2020-07-15 00:38:09 +0200 |
|---|---|---|
| committer | Thomas Vigouroux <39092278+vigoux@users.noreply.github.com> | 2020-07-15 16:28:48 +0200 |
| commit | 31d1f068fd0bec54af4250e9184227741297739a (patch) | |
| tree | e002bc76793af1ef26cbd4bca0b8f5ee85ef5f50 /lua | |
| parent | Use C++ parser for "cuda" filetype (diff) | |
| download | nvim-treesitter-31d1f068fd0bec54af4250e9184227741297739a.tar nvim-treesitter-31d1f068fd0bec54af4250e9184227741297739a.tar.gz nvim-treesitter-31d1f068fd0bec54af4250e9184227741297739a.tar.bz2 nvim-treesitter-31d1f068fd0bec54af4250e9184227741297739a.tar.lz nvim-treesitter-31d1f068fd0bec54af4250e9184227741297739a.tar.xz nvim-treesitter-31d1f068fd0bec54af4250e9184227741297739a.tar.zst nvim-treesitter-31d1f068fd0bec54af4250e9184227741297739a.zip | |
checkhealth for all query groups
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/nvim-treesitter/health.lua | 24 | ||||
| -rw-r--r-- | lua/nvim-treesitter/query.lua | 8 |
2 files changed, 13 insertions, 19 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) |
