mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
provider: has("python3_dynamic") et al. #10980
Vim added more flags for testing yet more dimensions of its Python
situation. Handle those in eval_has_provider().
vim-patch:8.0.1436: not enough information about what Python version may work
Problem: Not enough information about what Python version may work.
Solution: Add "python_compiled", "python3_compiled", "python_dynamic" and
"python3_dynamic" values for has().
ref: https://github.com/neovim/neovim/pull/10942#issuecomment-529479500
This commit is contained in:
@@ -24133,24 +24133,30 @@ typval_T eval_call_provider(char *provider, char *method, list_T *arguments)
|
|||||||
return rettv;
|
return rettv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if a named provider is enabled.
|
/// Checks if provider for feature `feat` is enabled.
|
||||||
bool eval_has_provider(const char *name)
|
bool eval_has_provider(const char *feat)
|
||||||
{
|
{
|
||||||
if (!strequal(name, "clipboard")
|
if (!strequal(feat, "clipboard")
|
||||||
&& !strequal(name, "python")
|
&& !strequal(feat, "python")
|
||||||
&& !strequal(name, "python3")
|
&& !strequal(feat, "python3")
|
||||||
&& !strequal(name, "ruby")
|
&& !strequal(feat, "python_compiled")
|
||||||
&& !strequal(name, "node")) {
|
&& !strequal(feat, "python_dynamic")
|
||||||
|
&& !strequal(feat, "python3_compiled")
|
||||||
|
&& !strequal(feat, "python3_dynamic")
|
||||||
|
&& !strequal(feat, "ruby")
|
||||||
|
&& !strequal(feat, "node")) {
|
||||||
// Avoid autoload for non-provider has() features.
|
// Avoid autoload for non-provider has() features.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char buf[256];
|
char name[32]; // Normalized: "python_compiled" => "python".
|
||||||
int len;
|
snprintf(name, sizeof(name), "%s", feat);
|
||||||
typval_T tv;
|
strchrsub(name, '_', '\0'); // Chop any "_xx" suffix.
|
||||||
|
|
||||||
|
char buf[256];
|
||||||
|
typval_T tv;
|
||||||
// Get the g:loaded_xx_provider variable.
|
// Get the g:loaded_xx_provider variable.
|
||||||
len = snprintf(buf, sizeof(buf), "g:loaded_%s_provider", name);
|
int len = snprintf(buf, sizeof(buf), "g:loaded_%s_provider", name);
|
||||||
if (get_var_tv(buf, len, &tv, NULL, false, true) == FAIL) {
|
if (get_var_tv(buf, len, &tv, NULL, false, true) == FAIL) {
|
||||||
// Trigger autoload once.
|
// Trigger autoload once.
|
||||||
len = snprintf(buf, sizeof(buf), "provider#%s#bogus", name);
|
len = snprintf(buf, sizeof(buf), "provider#%s#bogus", name);
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ describe('python3 provider', function()
|
|||||||
|
|
||||||
it('feature test', function()
|
it('feature test', function()
|
||||||
eq(1, eval('has("python3")'))
|
eq(1, eval('has("python3")'))
|
||||||
|
eq(1, eval('has("python3_compiled")'))
|
||||||
|
eq(1, eval('has("python3_dynamic")'))
|
||||||
|
eq(0, eval('has("python3_dynamic_")'))
|
||||||
|
eq(0, eval('has("python3_")'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('python3_execute', function()
|
it('python3_execute', function()
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ end)
|
|||||||
describe('python feature test', function()
|
describe('python feature test', function()
|
||||||
it('works', function()
|
it('works', function()
|
||||||
eq(1, funcs.has('python'))
|
eq(1, funcs.has('python'))
|
||||||
|
eq(1, funcs.has('python_compiled'))
|
||||||
|
eq(1, funcs.has('python_dynamic'))
|
||||||
|
eq(0, funcs.has('python_dynamic_'))
|
||||||
|
eq(0, funcs.has('python_'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user