1" The Ruby provider helper 2if exists('g:loaded_ruby_provider') 3 finish 4endif 5let g:loaded_ruby_provider = 1 6 7function! provider#ruby#Detect() abort 8 let e = empty(s:prog) ? 'missing ruby or ruby-host' : '' 9 return [s:prog, e] 10endfunction 11 12function! provider#ruby#Prog() abort 13 return s:prog 14endfunction 15 16function! provider#ruby#Require(host) abort 17 let prog = provider#ruby#Prog() 18 let ruby_plugins = remote#host#PluginsForHost(a:host.name) 19 20 for plugin in ruby_plugins 21 let prog .= " " . shellescape(plugin.path) 22 endfor 23 24 return provider#Poll(prog, a:host.orig_name, '$NVIM_RUBY_LOG_FILE') 25endfunction 26 27function! provider#ruby#Call(method, args) abort 28 if s:err != '' 29 echoerr s:err 30 return 31 endif 32 33 if !exists('s:host') 34 try 35 let s:host = remote#host#Require('legacy-ruby-provider') 36 catch 37 let s:err = v:exception 38 echohl WarningMsg 39 echomsg v:exception 40 echohl None 41 return 42 endtry 43 endif 44 return call('rpcrequest', insert(insert(a:args, 'ruby_'.a:method), s:host)) 45endfunction 46 47function! s:detect() 48 if exists("g:ruby_host_prog") 49 return expand(g:ruby_host_prog, v:true) 50 elseif has('win32') 51 return exepath('neovim-ruby-host.bat') 52 else 53 let p = exepath('neovim-ruby-host') 54 if empty(p) 55 return '' 56 endif 57 " neovim-ruby-host could be an rbenv shim for another Ruby version. 58 call system(p) 59 return v:shell_error ? '' : p 60 end 61endfunction 62 63let s:err = '' 64let s:prog = s:detect() 65let s:plugin_path = expand('<sfile>:p:h') . '/script_host.rb' 66let g:loaded_ruby_provider = empty(s:prog) ? 1 : 2 67 68if g:loaded_ruby_provider != 2 69 let s:err = 'Cannot find the neovim RubyGem. Try :checkhealth' 70endif 71 72call remote#host#RegisterClone('legacy-ruby-provider', 'ruby') 73call remote#host#RegisterPlugin('legacy-ruby-provider', s:plugin_path, []) 74