diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-08-04 12:06:24 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-08-04 13:23:46 +0200 |
commit | 241956720d02d933b0b27097a3b0a1966f138d0b (patch) | |
tree | 374bba71e8dd780fb7f89bd37ab28bbe5752c55e | |
parent | 66938b928c05b913f3a11e520d13ca854621799d (diff) | |
download | rneovim-241956720d02d933b0b27097a3b0a1966f138d0b.tar.gz rneovim-241956720d02d933b0b27097a3b0a1966f138d0b.tar.bz2 rneovim-241956720d02d933b0b27097a3b0a1966f138d0b.zip |
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().
-rw-r--r-- | runtime/autoload/provider/clipboard.vim | 6 | ||||
-rw-r--r-- | runtime/autoload/provider/node.vim | 6 | ||||
-rw-r--r-- | runtime/autoload/provider/python.vim | 2 | ||||
-rw-r--r-- | runtime/autoload/provider/python3.vim | 2 | ||||
-rw-r--r-- | runtime/autoload/provider/ruby.vim | 6 | ||||
-rw-r--r-- | runtime/doc/develop.txt | 6 | ||||
-rw-r--r-- | runtime/doc/provider.txt | 8 | ||||
-rw-r--r-- | src/nvim/eval.c | 4 | ||||
-rw-r--r-- | test/functional/fixtures/autoload/provider/brokencall.vim | 2 | ||||
-rw-r--r-- | test/functional/fixtures/autoload/provider/clipboard.vim | 2 |
10 files changed, 23 insertions, 21 deletions
diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim index 9b79e5abec..ce140b0948 100644 --- a/runtime/autoload/provider/clipboard.vim +++ b/runtime/autoload/provider/clipboard.vim @@ -5,11 +5,11 @@ if exists('g:loaded_clipboard_provider') finish endif -" Default to FALSE. Set by provider#clipboard#Executable() later. +" Default to 1. provider#clipboard#Executable() may set 2. " To force a reload: " :unlet g:loaded_clipboard_provider " :runtime autoload/provider/clipboard.vim -let g:loaded_clipboard_provider = 0 +let g:loaded_clipboard_provider = 1 let s:copy = {} let s:paste = {} @@ -197,4 +197,4 @@ function! provider#clipboard#Call(method, args) abort endfunction " eval_has_provider() decides based on this variable. -let g:loaded_clipboard_provider = !empty(provider#clipboard#Executable()) +let g:loaded_clipboard_provider = empty(provider#clipboard#Executable()) ? 1 : 2 diff --git a/runtime/autoload/provider/node.vim b/runtime/autoload/provider/node.vim index dd2423fe2a..b2a3b3ee08 100644 --- a/runtime/autoload/provider/node.vim +++ b/runtime/autoload/provider/node.vim @@ -1,7 +1,7 @@ if exists('g:loaded_node_provider') finish endif -let g:loaded_node_provider = 0 +let g:loaded_node_provider = 1 function! s:is_minimum_version(version, min_major, min_minor) abort if empty(a:version) @@ -140,9 +140,9 @@ endfunction let s:err = '' let s:prog = provider#node#Detect() -let g:loaded_node_provider = !empty(s:prog) +let g:loaded_node_provider = empty(s:prog) ? 1 : 2 -if !g:loaded_node_provider +if g:loaded_node_provider != 2 let s:err = 'Cannot find the "neovim" node package. Try :checkhealth' endif diff --git a/runtime/autoload/provider/python.vim b/runtime/autoload/provider/python.vim index 7921701141..8a1d162784 100644 --- a/runtime/autoload/provider/python.vim +++ b/runtime/autoload/provider/python.vim @@ -8,7 +8,7 @@ if exists('g:loaded_python_provider') finish endif let [s:prog, s:err] = provider#pythonx#Detect(2) -let g:loaded_python_provider = !empty(s:prog) +let g:loaded_python_provider = empty(s:prog) ? 1 : 2 function! provider#python#Prog() abort return s:prog 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 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('<sfile>: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 diff --git a/runtime/doc/develop.txt b/runtime/doc/develop.txt index 180612cf20..3262d9dec7 100644 --- a/runtime/doc/develop.txt +++ b/runtime/doc/develop.txt @@ -106,12 +106,12 @@ in eval.c: - eval_call_provider(name, method, arguments): calls provider#{name}#Call with the method and arguments. - eval_has_provider(name): Checks the `g:loaded_{name}_provider` variable - which must be set by the provider script to indicate whether it is enabled - and working. Called by |has()| to check if features are available. + which must be set to 2 by the provider script to indicate that it is + "enabled and working". Called by |has()| to check if features are available. For example, the Python provider is implemented by the "autoload/provider/python.vim" script, which sets `g:loaded_python_provider` -to TRUE only if a valid external Python host is found. Then `has("python")` +to 2 only if a valid external Python host is found. Then `has("python")` reflects whether Python support is working. *provider-reload* diff --git a/runtime/doc/provider.txt b/runtime/doc/provider.txt index 594c9602f4..dc045c360a 100644 --- a/runtime/doc/provider.txt +++ b/runtime/doc/provider.txt @@ -68,11 +68,11 @@ startup faster. Useful for working with virtualenvs. > < *g:loaded_python_provider* To disable Python 2 support: > - let g:loaded_python_provider = 1 + let g:loaded_python_provider = 0 < *g:loaded_python3_provider* To disable Python 3 support: > - let g:loaded_python3_provider = 1 + let g:loaded_python3_provider = 0 PYTHON VIRTUALENVS ~ @@ -111,7 +111,7 @@ Run |:checkhealth| to see if your system is up-to-date. RUBY PROVIDER CONFIGURATION ~ *g:loaded_ruby_provider* To disable Ruby support: > - let g:loaded_ruby_provider = 1 + let g:loaded_ruby_provider = 0 < *g:ruby_host_prog* Command to start the Ruby host. By default this is "neovim-ruby-host". With @@ -142,7 +142,7 @@ Run |:checkhealth| to see if your system is up-to-date. NODEJS PROVIDER CONFIGURATION~ *g:loaded_node_provider* To disable Node.js support: > - :let g:loaded_node_provider = 1 + :let g:loaded_node_provider = 0 < *g:node_host_prog* Command to start the Node.js host. Setting this makes startup faster. diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 6b7a359508..3bcec56b06 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -23996,7 +23996,9 @@ bool eval_has_provider(const char *provider) } } - return (tv.v_type == VAR_NUMBER) ? !!tv.vval.v_number : false; + return (tv.v_type == VAR_NUMBER) + ? 2 == tv.vval.v_number // Value of 2 means "loaded and working". + : false; } /// Writes "<sourcing_name>:<sourcing_lnum>" to `buf[bufsize]`. diff --git a/test/functional/fixtures/autoload/provider/brokencall.vim b/test/functional/fixtures/autoload/provider/brokencall.vim index 7dc5d828d2..cad2b2a640 100644 --- a/test/functional/fixtures/autoload/provider/brokencall.vim +++ b/test/functional/fixtures/autoload/provider/brokencall.vim @@ -1,2 +1,2 @@ " A dummy test provider -let g:loaded_brokencall_provider = 1 +let g:loaded_brokencall_provider = 2 diff --git a/test/functional/fixtures/autoload/provider/clipboard.vim b/test/functional/fixtures/autoload/provider/clipboard.vim index efa9f82bd4..41e486b745 100644 --- a/test/functional/fixtures/autoload/provider/clipboard.vim +++ b/test/functional/fixtures/autoload/provider/clipboard.vim @@ -1,4 +1,4 @@ -let g:loaded_clipboard_provider = 1 +let g:loaded_clipboard_provider = 2 let g:test_clip = { '+': [''], '*': [''], } |