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/python3.vim | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'runtime/autoload/provider/python3.vim') diff --git a/runtime/autoload/provider/python3.vim b/runtime/autoload/provider/python3.vim index 242a224cb3..469611c7ce 100644 --- a/runtime/autoload/provider/python3.vim +++ b/runtime/autoload/provider/python3.vim @@ -10,6 +10,7 @@ endif let g:loaded_python3_provider = 1 let [s:prog, s:err] = provider#pythonx#Detect(3) +let g:provider#python3#enabled = !empty(s:prog) function! provider#python3#Prog() abort return s:prog @@ -19,11 +20,6 @@ function! provider#python3#Error() abort return s:err endfunction -if s:prog == '' - " Detection failed - finish -endif - " The Python3 provider plugin will run in a separate instance of the Python3 " host. call remote#host#RegisterClone('legacy-python3-provider', 'python3') -- 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/python3.vim | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'runtime/autoload/provider/python3.vim') diff --git a/runtime/autoload/provider/python3.vim b/runtime/autoload/provider/python3.vim index 469611c7ce..67350e3753 100644 --- a/runtime/autoload/provider/python3.vim +++ b/runtime/autoload/provider/python3.vim @@ -7,10 +7,8 @@ if exists('g:loaded_python3_provider') finish endif -let g:loaded_python3_provider = 1 - let [s:prog, s:err] = provider#pythonx#Detect(3) -let g:provider#python3#enabled = !empty(s:prog) +let g:loaded_python3_provider = !empty(s:prog) function! provider#python3#Prog() abort return s:prog -- 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/python3.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/autoload/provider/python3.vim') diff --git a/runtime/autoload/provider/python3.vim b/runtime/autoload/provider/python3.vim index 67350e3753..38ef0cccfc 100644 --- a/runtime/autoload/provider/python3.vim +++ b/runtime/autoload/provider/python3.vim @@ -8,7 +8,7 @@ if exists('g:loaded_python3_provider') finish endif let [s:prog, s:err] = provider#pythonx#Detect(3) -let g:loaded_python3_provider = !empty(s:prog) +let g:loaded_python3_provider = empty(s:prog) ? 1 : 2 function! provider#python3#Prog() abort return s:prog -- cgit