diff options
| author | Javier López <graulopezjavier@gmail.com> | 2021-10-06 09:29:08 -0500 |
|---|---|---|
| committer | Thomas Vigouroux <tomvig38@gmail.com> | 2021-10-11 09:47:16 +0200 |
| commit | 66f1873213617a334d4a7af947dad5b2b796dab2 (patch) | |
| tree | 265ca312f555c8868a1b4d68f481475c9902731d | |
| parent | ea0f6614b7f67d141b68a8c68dcfbe0dca19009a (diff) | |
feat(healthcheck): support native lua healthchecks, and fixes
After neovim/neovim#15259 lua healthchecks are called directly and are
prefered over neovim autoload ones. The discover of Lua ones requires
the function to be named "check()".
Also the mentioned PR changed the design of healthchecks to not use
output capturing, therefore avoid printing and instead concatenate and
call the health functions.
| -rw-r--r-- | .github/ISSUE_TEMPLATE/bug_report.yml | 2 | ||||
| -rw-r--r-- | autoload/health/nvim_treesitter.vim | 2 | ||||
| -rw-r--r-- | lua/nvim-treesitter/health.lua | 17 |
3 files changed, 12 insertions, 9 deletions
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 01e8a3c6..d770c35f 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -41,7 +41,7 @@ body: - type: textarea attributes: - label: Output of `:checkhealth nvim_treesitter` + label: Output of `:checkhealth nvim-treesitter` render: markdown validations: required: true diff --git a/autoload/health/nvim_treesitter.vim b/autoload/health/nvim_treesitter.vim index e388f6f1..53e187cd 100644 --- a/autoload/health/nvim_treesitter.vim +++ b/autoload/health/nvim_treesitter.vim @@ -1,3 +1,3 @@ function! health#nvim_treesitter#check() - lua require 'nvim-treesitter.health'.checkhealth() + lua require 'nvim-treesitter.health'.check() endfunction diff --git a/lua/nvim-treesitter/health.lua b/lua/nvim-treesitter/health.lua index 9c65462b..996a87f2 100644 --- a/lua/nvim-treesitter/health.lua +++ b/lua/nvim-treesitter/health.lua @@ -109,17 +109,17 @@ local function query_status(lang, query_group) end end -function M.checkhealth() +function M.check() local error_collection = {} -- Installation dependency checks install_health() queries.invalidate_query_cache() - health_start "Parser/Features H L F I J" -- Parser installation checks + local parser_installation = { "Parser/Features H L F I J" } for _, parser_name in pairs(info.installed_parsers()) do local installed = #api.nvim_get_runtime_file("parser/" .. parser_name .. ".so", false) - -- Only print informations about installed parsers + -- Only append information about installed parsers if installed >= 1 then local multiple_parsers = installed > 1 and "+" or "" local out = " - " .. parser_name .. multiple_parsers .. string.rep(" ", 15 - (#parser_name + #multiple_parsers)) @@ -130,16 +130,19 @@ function M.checkhealth() table.insert(error_collection, { parser_name, query_group, err }) end end - print(out) + table.insert(parser_installation, out) end end - print [[ + local legend = [[ - Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections + Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections +) multiple parsers found, only one will be used x) errors found in the query, try to run :TSUpdate {lang}]] + table.insert(parser_installation, legend) + -- Finally call the report function + health_start(table.concat(parser_installation, "\n")) if #error_collection > 0 then - print "\nThe following errors have been detected:" + health_start "The following errors have been detected:" for _, p in ipairs(error_collection) do local lang, type, err = unpack(p) health_error(lang .. "(" .. type .. "): " .. err) |
