mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
provider: check #Call() if g:loaded_xx_provider=2
This commit is contained in:
@@ -23996,8 +23996,7 @@ bool eval_has_provider(const char *name)
|
|||||||
if (get_var_tv(buf, len, &tv, NULL, false, true) == FAIL) {
|
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.
|
// Show a hint if Call() is defined but g:loaded_xx_provider is missing.
|
||||||
snprintf(buf, sizeof(buf), "provider#%s#Call", name);
|
snprintf(buf, sizeof(buf), "provider#%s#Call", name);
|
||||||
bool has_call = !!find_func((char_u *)buf);
|
if (!!find_func((char_u *)buf) && p_lpl) {
|
||||||
if (has_call && p_lpl) {
|
|
||||||
emsgf("provider: %s: missing required variable g:loaded_%s_provider",
|
emsgf("provider: %s: missing required variable g:loaded_%s_provider",
|
||||||
name, name);
|
name, name);
|
||||||
}
|
}
|
||||||
@@ -24005,9 +24004,21 @@ bool eval_has_provider(const char *name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (tv.v_type == VAR_NUMBER)
|
bool ok = (tv.v_type == VAR_NUMBER)
|
||||||
? 2 == tv.vval.v_number // Value of 2 means "loaded and working".
|
? 2 == tv.vval.v_number // Value of 2 means "loaded and working".
|
||||||
: false;
|
: false;
|
||||||
|
|
||||||
|
if (ok) {
|
||||||
|
// Call() must be defined if provider claims to be working.
|
||||||
|
snprintf(buf, sizeof(buf), "provider#%s#Call", name);
|
||||||
|
if (!find_func((char_u *)buf)) {
|
||||||
|
emsgf("provider: %s: g:loaded_%s_provider=2 but %s is not defined",
|
||||||
|
name, name, buf);
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Writes "<sourcing_name>:<sourcing_lnum>" to `buf[bufsize]`.
|
/// Writes "<sourcing_name>:<sourcing_lnum>" to `buf[bufsize]`.
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local clear, eq, eval = helpers.clear, helpers.eq, helpers.eval
|
local clear, eval = helpers.clear, helpers.eval
|
||||||
local command = helpers.command
|
local command = helpers.command
|
||||||
local expect_err = helpers.expect_err
|
local expect_err = helpers.expect_err
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ describe('providers', function()
|
|||||||
clear('--cmd', 'let &rtp = "test/functional/fixtures,".&rtp')
|
clear('--cmd', 'let &rtp = "test/functional/fixtures,".&rtp')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('must define g:loaded_xx_provider', function()
|
it('with #Call(), missing g:loaded_xx_provider', function()
|
||||||
command('set loadplugins')
|
command('set loadplugins')
|
||||||
-- Using test-fixture with broken impl:
|
-- Using test-fixture with broken impl:
|
||||||
-- test/functional/fixtures/autoload/provider/python.vim
|
-- test/functional/fixtures/autoload/provider/python.vim
|
||||||
@@ -17,9 +17,10 @@ describe('providers', function()
|
|||||||
eval, "has('python')")
|
eval, "has('python')")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('without Call() but with g:loaded_xx_provider', function()
|
it('with g:loaded_xx_provider, missing #Call()', function()
|
||||||
-- Using test-fixture with broken impl:
|
-- Using test-fixture with broken impl:
|
||||||
-- test/functional/fixtures/autoload/provider/ruby.vim
|
-- test/functional/fixtures/autoload/provider/ruby.vim
|
||||||
eq(1, eval("has('ruby')"))
|
expect_err('Vim:provider: ruby: g:loaded_ruby_provider=2 but provider#ruby#Call is not defined',
|
||||||
|
eval, "has('ruby')")
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user