aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-08-04 12:20:30 +0200
committerJustin M. Keyes <justinkz@gmail.com>2019-08-04 13:23:46 +0200
commit5e6a08f2e6b21e83c9fb381042f0aed89de4598d (patch)
treef219b253e9543c31e4792394a110c089db766895
parent241956720d02d933b0b27097a3b0a1966f138d0b (diff)
downloadrneovim-5e6a08f2e6b21e83c9fb381042f0aed89de4598d.tar.gz
rneovim-5e6a08f2e6b21e83c9fb381042f0aed89de4598d.tar.bz2
rneovim-5e6a08f2e6b21e83c9fb381042f0aed89de4598d.zip
provider: skip non-provider has() feature-names
We don't want to retry autoload sourcing (slow) for every random has() query that finds it way to eval_call_provider().
-rw-r--r--src/nvim/eval.c23
-rw-r--r--test/functional/fixtures/autoload/provider/brokencall.vim2
-rw-r--r--test/functional/fixtures/autoload/provider/python.vim (renamed from test/functional/fixtures/autoload/provider/brokenenabled.vim)2
-rw-r--r--test/functional/fixtures/autoload/provider/ruby.vim2
-rw-r--r--test/functional/provider/provider_spec.lua10
5 files changed, 26 insertions, 13 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 3bcec56b06..dc18532b40 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -23969,28 +23969,37 @@ typval_T eval_call_provider(char *provider, char *method, list_T *arguments)
}
/// Checks if a named provider is enabled.
-bool eval_has_provider(const char *provider)
-{
+bool eval_has_provider(const char *name)
+{
+ if (!strequal(name, "clipboard")
+ && !strequal(name, "python")
+ && !strequal(name, "python3")
+ && !strequal(name, "ruby")
+ && !strequal(name, "node")) {
+ // Avoid autoload for non-provider has() features.
+ return false;
+ }
+
char buf[256];
int len;
typval_T tv;
// Get the g:loaded_xx_provider variable.
- len = snprintf(buf, sizeof(buf), "g:loaded_%s_provider", provider);
+ len = snprintf(buf, sizeof(buf), "g:loaded_%s_provider", name);
if (get_var_tv(buf, len, &tv, NULL, false, true) == FAIL) {
// Trigger autoload once.
- len = snprintf(buf, sizeof(buf), "provider#%s#bogus", provider);
+ len = snprintf(buf, sizeof(buf), "provider#%s#bogus", name);
script_autoload(buf, len, false);
// Retry the (non-autoload-style) variable.
- len = snprintf(buf, sizeof(buf), "g:loaded_%s_provider", provider);
+ len = snprintf(buf, sizeof(buf), "g:loaded_%s_provider", name);
if (get_var_tv(buf, len, &tv, NULL, false, true) == FAIL) {
// Show a hint if Call() is defined but g:loaded_xx_provider is missing.
- snprintf(buf, sizeof(buf), "provider#%s#Call", provider);
+ snprintf(buf, sizeof(buf), "provider#%s#Call", name);
bool has_call = !!find_func((char_u *)buf);
if (has_call && p_lpl) {
emsgf("provider: %s: missing required variable g:loaded_%s_provider",
- provider, provider);
+ name, name);
}
return false;
}
diff --git a/test/functional/fixtures/autoload/provider/brokencall.vim b/test/functional/fixtures/autoload/provider/brokencall.vim
deleted file mode 100644
index cad2b2a640..0000000000
--- a/test/functional/fixtures/autoload/provider/brokencall.vim
+++ /dev/null
@@ -1,2 +0,0 @@
-" A dummy test provider
-let g:loaded_brokencall_provider = 2
diff --git a/test/functional/fixtures/autoload/provider/brokenenabled.vim b/test/functional/fixtures/autoload/provider/python.vim
index dd33ce66f3..d68360ac30 100644
--- a/test/functional/fixtures/autoload/provider/brokenenabled.vim
+++ b/test/functional/fixtures/autoload/provider/python.vim
@@ -1,6 +1,6 @@
" Dummy test provider, missing this required variable:
" let g:loaded_brokenenabled_provider = 0
-function! provider#brokenenabled#Call(method, args)
+function! provider#python#Call(method, args)
return 42
endfunction
diff --git a/test/functional/fixtures/autoload/provider/ruby.vim b/test/functional/fixtures/autoload/provider/ruby.vim
new file mode 100644
index 0000000000..35becc27ff
--- /dev/null
+++ b/test/functional/fixtures/autoload/provider/ruby.vim
@@ -0,0 +1,2 @@
+" A dummy test provider
+let g:loaded_ruby_provider = 2
diff --git a/test/functional/provider/provider_spec.lua b/test/functional/provider/provider_spec.lua
index b690cf2566..4220ec21cf 100644
--- a/test/functional/provider/provider_spec.lua
+++ b/test/functional/provider/provider_spec.lua
@@ -11,11 +11,15 @@ describe('providers', function()
it('must define g:loaded_xx_provider', function()
command('set loadplugins')
- expect_err('Vim:provider: brokenenabled: missing required variable g:loaded_brokenenabled_provider',
- eval, "has('brokenenabled')")
+ -- Using test-fixture with broken impl:
+ -- test/functional/fixtures/autoload/provider/python.vim
+ expect_err('Vim:provider: python: missing required variable g:loaded_python_provider',
+ eval, "has('python')")
end)
it('without Call() but with g:loaded_xx_provider', function()
- eq(1, eval("has('brokencall')"))
+ -- Using test-fixture with broken impl:
+ -- test/functional/fixtures/autoload/provider/ruby.vim
+ eq(1, eval("has('ruby')"))
end)
end)