diff options
-rw-r--r-- | runtime/lua/vim/health/health.lua | 10 | ||||
-rw-r--r-- | runtime/lua/vim/provider/health.lua | 27 |
2 files changed, 24 insertions, 13 deletions
diff --git a/runtime/lua/vim/health/health.lua b/runtime/lua/vim/health/health.lua index 38fcd64f88..dd6fe7f608 100644 --- a/runtime/lua/vim/health/health.lua +++ b/runtime/lua/vim/health/health.lua @@ -110,16 +110,6 @@ local function check_config() ) end - if vim.g.loaded_python3_provider == 1 then - ok = false - health.error( - '`g:loaded_python3_provider=1` may have been set by mistake. This option should not be used to load python provider in your config.', - { - 'Remove `vim.g.loaded_python3_provider=1` from your config.', - } - ) - end - local writeable = true local shadaopt = vim.fn.split(vim.o.shada, ',') local shadafile = ( diff --git a/runtime/lua/vim/provider/health.lua b/runtime/lua/vim/provider/health.lua index fa01951b02..28eb776355 100644 --- a/runtime/lua/vim/provider/health.lua +++ b/runtime/lua/vim/provider/health.lua @@ -107,9 +107,22 @@ local function provider_disabled(provider) return false end +--- Checks the hygiene of a `g:loaded_xx_provider` variable. +local function check_loaded_var(var) + if vim.g[var] == 1 then + health.error(('`g:%s=1` may have been set by mistake.'):format(var), { + ('Remove `vim.g.%s=1` from your config.'):format(var), + 'To disable the provider, set this to 0, not 1.', + 'If you want to enable the provider but skip automatic detection, set the respective `g:…_host_prog` var. See :help provider', + }) + end +end + local function clipboard() health.start('Clipboard (optional)') + check_loaded_var('loaded_clipboard_provider') + if os.getenv('TMUX') and vim.fn.executable('tmux') == 1 @@ -144,6 +157,8 @@ end local function node() health.start('Node.js provider (optional)') + check_loaded_var('loaded_node_provider') + if provider_disabled('node') then return end @@ -247,6 +262,8 @@ end local function perl() health.start('Perl provider (optional)') + check_loaded_var('loaded_perl_provider') + if provider_disabled('perl') then return end @@ -256,7 +273,7 @@ local function perl() if not perl_exec then health.warn(assert(perl_warnings), { 'See :help provider-perl for more information.', - 'You may disable this provider (and warning) by adding `let g:loaded_perl_provider = 0` to your init.vim', + 'You can disable this provider (and warning) by adding `let g:loaded_perl_provider = 0` to your init.vim', }) health.warn('No usable perl executable found') return @@ -561,6 +578,8 @@ end local function python() health.start('Python 3 provider (optional)') + check_loaded_var('loaded_python3_provider') + local python_exe = '' local virtual_env = os.getenv('VIRTUAL_ENV') local venv = virtual_env and vim.fn.resolve(virtual_env) or '' @@ -595,7 +614,7 @@ local function python() if pythonx_warnings then health.warn(pythonx_warnings, { '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', + 'You can disable this provider (and warning) by adding `let g:loaded_python3_provider = 0` to your init.vim', }) elseif pyname and pyname ~= '' and python_exe == '' then if not vim.g[host_prog_var] then @@ -840,6 +859,8 @@ end local function ruby() health.start('Ruby provider (optional)') + check_loaded_var('loaded_ruby_provider') + if provider_disabled('ruby') then return end @@ -860,7 +881,7 @@ local function ruby() 'Run `gem environment` to ensure the gem bin directory is in $PATH.', 'If you are using rvm/rbenv/chruby, try "rehashing".', 'See :help g:ruby_host_prog for non-standard gem installations.', - 'You may disable this provider (and warning) by adding `let g:loaded_ruby_provider = 0` to your init.vim', + 'You can disable this provider (and warning) by adding `let g:loaded_ruby_provider = 0` to your init.vim', }) return end |