fix(health): "attempt to concatenate nil"

Problem:
If `neovim` module is not installed, python and ruby healthchecks fail:

    - ERROR Failed to run healthcheck for "provider.python" plugin. Exception:
      .../runtime/lua/provider/python/health.lua:348: attempt to concatenate local 'pyname' (a nil value)
    - ERROR Failed to run healthcheck for "provider.ruby" plugin. Exception:
      .../runtime/lua/provider/ruby/health.lua:25: attempt to index local 'host' (a nil value)

Solution:
Check for non-nil.
This commit is contained in:
Justin M. Keyes 2024-01-28 12:59:22 -08:00
parent 50cd5ed360
commit e39b6d0c52
2 changed files with 3 additions and 3 deletions

View File

@ -255,7 +255,7 @@ function M.check()
'See :help provider-python for more information.',
'You may disable this provider (and warning) by adding `let g:loaded_python3_provider = 0` to your init.vim',
})
elseif pyname ~= '' and python_exe == '' then
elseif pyname and pyname ~= '' and python_exe == '' then
if not vim.g[host_prog_var] then
local message = string.format(
'`g:%s` is not set. Searching for %s in the environment.',
@ -343,7 +343,7 @@ function M.check()
end
end
if python_exe == '' and pyname ~= '' then
if pyname and python_exe == '' and pyname ~= '' then
-- An error message should have already printed.
health.error('`' .. pyname .. '` was not found.')
elseif python_exe ~= '' and not check_bin(python_exe) then

View File

@ -22,7 +22,7 @@ function M.check()
local ruby_detect_table = require('vim.provider.ruby').detect()
local host = ruby_detect_table[1]
if host:find('^%s*$') then
if (not host) or host:find('^%s*$') then
health.warn('`neovim-ruby-host` not found.', {
'Run `gem install neovim` to ensure the neovim RubyGem is installed.',
'Run `gem environment` to ensure the gem bin directory is in $PATH.',