aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2018-12-13 02:40:54 +0100
committerGitHub <noreply@github.com>2018-12-13 02:40:54 +0100
commitaf368981a7ce817391a03dae5816d167aa2dc189 (patch)
treeac7cb5c113364f78052240cf6b90229d354f120a
parent2f3a18695e41ec6afa98194b22d064ec81154dbf (diff)
parent315769ae6dc3b3c7613f8e3f2f78fbe24b950477 (diff)
downloadrneovim-af368981a7ce817391a03dae5816d167aa2dc189.tar.gz
rneovim-af368981a7ce817391a03dae5816d167aa2dc189.tar.bz2
rneovim-af368981a7ce817391a03dae5816d167aa2dc189.zip
Merge #9355 from mhinz/ruby-provider-path
provider: make :ruby provider check use same code path as :python
-rw-r--r--src/nvim/eval.c22
-rw-r--r--test/functional/provider/ruby_spec.lua5
2 files changed, 16 insertions, 11 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index cd29e4ef19..d67818aa81 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -10802,17 +10802,6 @@ static void f_has(typval_T *argvars, typval_T *rettv, FunPtr fptr)
n = true;
}
- if (STRICMP(name, "ruby") == 0 && n == true) {
- char *rubyhost = call_func_retstr("provider#ruby#Detect", 0, NULL, true);
- if (rubyhost) {
- if (*rubyhost == NUL) {
- // Invalid rubyhost executable. Gem is probably not installed.
- n = false;
- }
- xfree(rubyhost);
- }
- }
-
rettv->vval.v_number = n;
}
@@ -22770,7 +22759,18 @@ bool eval_has_provider(const char *name)
CHECK_PROVIDER(python);
return has_python;
} else if (strequal(name, "ruby")) {
+ bool need_check_ruby = (has_ruby == -1);
CHECK_PROVIDER(ruby);
+ if (need_check_ruby && has_ruby == 1) {
+ char *rubyhost = call_func_retstr("provider#ruby#Detect", 0, NULL, true);
+ if (rubyhost) {
+ if (*rubyhost == NUL) {
+ // Invalid rubyhost executable. Gem is probably not installed.
+ has_ruby = 0;
+ }
+ xfree(rubyhost);
+ }
+ }
return has_ruby;
}
diff --git a/test/functional/provider/ruby_spec.lua b/test/functional/provider/ruby_spec.lua
index e049ac7c41..40cfe80b50 100644
--- a/test/functional/provider/ruby_spec.lua
+++ b/test/functional/provider/ruby_spec.lua
@@ -6,6 +6,7 @@ local curbufmeths = helpers.curbufmeths
local eq = helpers.eq
local eval = helpers.eval
local expect = helpers.expect
+local expect_err = helpers.expect_err
local feed = helpers.feed
local feed_command = helpers.feed_command
local funcs = helpers.funcs
@@ -17,6 +18,10 @@ local write_file = helpers.write_file
do
clear()
if missing_provider('ruby') then
+ it(':ruby reports E319 if provider is missing', function()
+ expect_err([[Vim%(ruby%):E319: No "ruby" provider found.*]],
+ command, 'ruby puts "foo"')
+ end)
pending("Missing neovim RubyGem.", function() end)
return
end