diff options
-rw-r--r-- | runtime/autoload/provider/ruby.vim | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/runtime/autoload/provider/ruby.vim b/runtime/autoload/provider/ruby.vim index 2fe3817512..ed9436750b 100644 --- a/runtime/autoload/provider/ruby.vim +++ b/runtime/autoload/provider/ruby.vim @@ -5,11 +5,7 @@ endif let g:loaded_ruby_provider = 1 function! provider#ruby#Detect() abort - if exists("g:ruby_host_prog") - return g:ruby_host_prog - else - return has('win32') ? exepath('neovim-ruby-host.bat') : exepath('neovim-ruby-host') - end + return s:prog endfunction function! provider#ruby#Prog() abort @@ -47,8 +43,24 @@ function! provider#ruby#Call(method, args) abort return call('rpcrequest', insert(insert(a:args, 'ruby_'.a:method), s:host)) endfunction +function! s:detect() + if exists("g:ruby_host_prog") + return g:ruby_host_prog + elseif has('win32') + return exepath('neovim-ruby-host.bat') + else + let p = exepath('neovim-ruby-host') + if empty(p) + return '' + endif + " neovim-ruby-host could be an rbenv shim for another Ruby version. + call system(p) + return v:shell_error ? '' : p + end +endfunction + let s:err = '' -let s:prog = provider#ruby#Detect() +let s:prog = s:detect() let s:plugin_path = expand('<sfile>:p:h') . '/script_host.rb' if empty(s:prog) |