aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-09-09 10:54:07 -0700
committerGitHub <noreply@github.com>2019-09-09 10:54:07 -0700
commit853683e72a780afef3ecebd8d46e32983abe1798 (patch)
tree911dd8fe1c894ea27eb401091882fdab4a433dd3
parent225941ddd0b85a7570fe29a993868e4f5948c1f4 (diff)
downloadrneovim-853683e72a780afef3ecebd8d46e32983abe1798.tar.gz
rneovim-853683e72a780afef3ecebd8d46e32983abe1798.tar.bz2
rneovim-853683e72a780afef3ecebd8d46e32983abe1798.zip
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
-rw-r--r--src/nvim/eval.c28
-rw-r--r--test/functional/provider/python3_spec.lua4
-rw-r--r--test/functional/provider/python_spec.lua4
3 files changed, 25 insertions, 11 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 0aa0e8c165..b067e03c2f 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -24133,24 +24133,30 @@ typval_T eval_call_provider(char *provider, char *method, list_T *arguments)
return rettv;
}
-/// Checks if a named provider is enabled.
-bool eval_has_provider(const char *name)
-{
- if (!strequal(name, "clipboard")
- && !strequal(name, "python")
- && !strequal(name, "python3")
- && !strequal(name, "ruby")
- && !strequal(name, "node")) {
+/// Checks if provider for feature `feat` is enabled.
+bool eval_has_provider(const char *feat)
+{
+ if (!strequal(feat, "clipboard")
+ && !strequal(feat, "python")
+ && !strequal(feat, "python3")
+ && !strequal(feat, "python_compiled")
+ && !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.
return false;
}
+ char name[32]; // Normalized: "python_compiled" => "python".
+ snprintf(name, sizeof(name), "%s", feat);
+ strchrsub(name, '_', '\0'); // Chop any "_xx" suffix.
+
char buf[256];
- int len;
typval_T tv;
-
// 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) {
// Trigger autoload once.
len = snprintf(buf, sizeof(buf), "provider#%s#bogus", name);
diff --git a/test/functional/provider/python3_spec.lua b/test/functional/provider/python3_spec.lua
index d7ca0bd420..b319d5e948 100644
--- a/test/functional/provider/python3_spec.lua
+++ b/test/functional/provider/python3_spec.lua
@@ -29,6 +29,10 @@ describe('python3 provider', function()
it('feature test', function()
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)
it('python3_execute', function()
diff --git a/test/functional/provider/python_spec.lua b/test/functional/provider/python_spec.lua
index eab4b29d3a..986f10b2e9 100644
--- a/test/functional/provider/python_spec.lua
+++ b/test/functional/provider/python_spec.lua
@@ -37,6 +37,10 @@ end)
describe('python feature test', function()
it('works', function()
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)