From 2cfe4748e57bd510b98ca81bd915f801f5a50bb5 Mon Sep 17 00:00:00 2001 From: Rui Abreu Ferreira Date: Sun, 9 Jun 2019 18:22:10 +0100 Subject: provider: let providers decide their status Instead of deciding provider status in eval_has_provider, move the decision to the provider Vim scripts. Previously, provider loading worked as follows: 1. eval_has_provider() verified provider availability by searching for the provider#providername#Call function and cached this verificaion as a static variable for some providers 2. providers short-circuited on loading to prevent the definition of the Call function (with the exception of the node provider that did not) This commit changes the expected interface between nvim and its providers to facilitate provider reloading, by splitting the verification of the provider from the availability of the Call function. eval_has_provider() now checks for a provider#providername#enabled variable. It is up to the provider script to set this to 0 or 1 accordingly. eval_call_provider() remains unchanged. All providers hosting a Call function were updated to respect this. The clipboard provider now has a Reload function to reload the provider. --- runtime/autoload/provider/ruby.vim | 3 +++ 1 file changed, 3 insertions(+) (limited to 'runtime/autoload/provider/ruby.vim') diff --git a/runtime/autoload/provider/ruby.vim b/runtime/autoload/provider/ruby.vim index 3b4c6c4839..df43dffa40 100644 --- a/runtime/autoload/provider/ruby.vim +++ b/runtime/autoload/provider/ruby.vim @@ -7,6 +7,7 @@ let g:loaded_ruby_provider = 1 function! provider#ruby#Detect() abort return s:prog endfunction +let g:provider#ruby#enabled = 0 function! provider#ruby#Prog() abort return s:prog @@ -65,6 +66,8 @@ let s:plugin_path = expand(':p:h') . '/script_host.rb' if empty(s:prog) let s:err = 'Cannot find the neovim RubyGem. Try :checkhealth' +else + let g:provider#ruby#enabled = 1 endif call remote#host#RegisterClone('legacy-ruby-provider', 'ruby') -- cgit From 66938b928c05b913f3a11e520d13ca854621799d Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 4 Aug 2019 03:54:06 +0200 Subject: provider: decide status by g:loaded_xx_provider --- runtime/autoload/provider/ruby.vim | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'runtime/autoload/provider/ruby.vim') diff --git a/runtime/autoload/provider/ruby.vim b/runtime/autoload/provider/ruby.vim index df43dffa40..f9d4f2b885 100644 --- a/runtime/autoload/provider/ruby.vim +++ b/runtime/autoload/provider/ruby.vim @@ -2,12 +2,11 @@ if exists('g:loaded_ruby_provider') finish endif -let g:loaded_ruby_provider = 1 +let g:loaded_ruby_provider = 0 function! provider#ruby#Detect() abort return s:prog endfunction -let g:provider#ruby#enabled = 0 function! provider#ruby#Prog() abort return s:prog @@ -63,11 +62,10 @@ endfunction let s:err = '' let s:prog = s:detect() let s:plugin_path = expand(':p:h') . '/script_host.rb' +let g:loaded_ruby_provider = !empty(s:prog) -if empty(s:prog) +if !g:loaded_ruby_provider let s:err = 'Cannot find the neovim RubyGem. Try :checkhealth' -else - let g:provider#ruby#enabled = 1 endif call remote#host#RegisterClone('legacy-ruby-provider', 'ruby') -- cgit From 241956720d02d933b0b27097a3b0a1966f138d0b Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 4 Aug 2019 12:06:24 +0200 Subject: provider: g:loaded_xx_provider=2 means "enabled and working" Value of 1 cannot be used, because users might set that in their vimrc to _disable_ a provider, which would confuse :checkhealth and has(). --- runtime/autoload/provider/ruby.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'runtime/autoload/provider/ruby.vim') diff --git a/runtime/autoload/provider/ruby.vim b/runtime/autoload/provider/ruby.vim index f9d4f2b885..f843050df9 100644 --- a/runtime/autoload/provider/ruby.vim +++ b/runtime/autoload/provider/ruby.vim @@ -2,7 +2,7 @@ if exists('g:loaded_ruby_provider') finish endif -let g:loaded_ruby_provider = 0 +let g:loaded_ruby_provider = 1 function! provider#ruby#Detect() abort return s:prog @@ -62,9 +62,9 @@ endfunction let s:err = '' let s:prog = s:detect() let s:plugin_path = expand(':p:h') . '/script_host.rb' -let g:loaded_ruby_provider = !empty(s:prog) +let g:loaded_ruby_provider = empty(s:prog) ? 1 : 2 -if !g:loaded_ruby_provider +if g:loaded_ruby_provider != 2 let s:err = 'Cannot find the neovim RubyGem. Try :checkhealth' endif -- cgit