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