fix(checkhealth): skip vim.health #18816

Problem:
https://github.com/neovim/neovim/pull/18720#issuecomment-1142614996

The vim.health module is detected as a healthcheck, which produces spurious errors:

    vim: require("vim.health").check()
    ========================================================================
    - ERROR: Failed to run healthcheck for "vim" plugin. Exception:
      function health#check, line 20
      Vim(eval):E5108: Error executing lua [string "luaeval()"]:1: attempt to call field 'check' (a nil value)
      stack traceback:
      [string "luaeval()"]:1: in main chunk

Solution:
Skip vim.health when discovering healthchecks.
This commit is contained in:
Javier Lopez
2022-06-01 09:10:10 -05:00
committed by GitHub
parent 96c494dec3
commit d837b6d50c
3 changed files with 16 additions and 1 deletions

View File

@@ -171,6 +171,11 @@ function! s:get_healthcheck(plugin_names) abort
for v in values(healthchecks) for v in values(healthchecks)
let output[v[0]] = v[1:] let output[v[0]] = v[1:]
endfor endfor
try
" vim.health is not a healthcheck, skip it
call remove(output, 'vim')
catch
endtry
return output return output
endfunction endfunction

View File

@@ -41,6 +41,8 @@ M._complete = function()
vim.tbl_map(function(f) vim.tbl_map(function(f)
unique[f] = true unique[f] = true
end, names) end, names)
-- vim.health is this file, which is not a healthcheck
unique['vim'] = nil
return vim.tbl_keys(unique) return vim.tbl_keys(unique)
end end

View File

@@ -5,7 +5,7 @@ local Screen = require('test.functional.ui.screen')
local clear = helpers.clear local clear = helpers.clear
local curbuf_contents = helpers.curbuf_contents local curbuf_contents = helpers.curbuf_contents
local command = helpers.command local command = helpers.command
local eq = helpers.eq local eq, neq = helpers.eq, helpers.neq
local getcompletion = helpers.funcs.getcompletion local getcompletion = helpers.funcs.getcompletion
describe(':checkhealth', function() describe(':checkhealth', function()
@@ -37,6 +37,7 @@ describe(':checkhealth', function()
eq('nvim', getcompletion('nvim', 'checkhealth')[1]) eq('nvim', getcompletion('nvim', 'checkhealth')[1])
eq('provider', getcompletion('prov', 'checkhealth')[1]) eq('provider', getcompletion('prov', 'checkhealth')[1])
eq('vim.lsp', getcompletion('vim.ls', 'checkhealth')[1]) eq('vim.lsp', getcompletion('vim.ls', 'checkhealth')[1])
neq('vim', getcompletion('^vim', 'checkhealth')[1]) -- should not complete vim.health
end) end)
end) end)
@@ -242,6 +243,13 @@ describe('health.vim', function()
- ERROR: No healthcheck found for "non_existent_healthcheck" plugin. - ERROR: No healthcheck found for "non_existent_healthcheck" plugin.
]]) ]])
end) end)
it("does not use vim.health as a healtcheck", function()
-- vim.health is not a healthcheck
command("checkhealth vim")
helpers.expect([[
ERROR: No healthchecks found.]])
end)
end) end)
end) end)