2016-03-10 19:56:47 -07:00
|
|
|
" The Ruby provider helper
|
2017-02-13 16:00:29 -07:00
|
|
|
if exists('g:loaded_ruby_provider')
|
2016-03-10 19:56:47 -07:00
|
|
|
finish
|
|
|
|
endif
|
2016-07-02 21:45:48 -07:00
|
|
|
let g:loaded_ruby_provider = 1
|
2016-03-10 19:56:47 -07:00
|
|
|
|
2016-07-02 21:45:48 -07:00
|
|
|
function! provider#ruby#Detect() abort
|
2018-08-08 15:47:35 -07:00
|
|
|
return s:prog
|
2016-07-02 21:45:48 -07:00
|
|
|
endfunction
|
|
|
|
|
2017-12-17 07:53:11 -07:00
|
|
|
function! provider#ruby#Prog() abort
|
2016-07-02 21:45:48 -07:00
|
|
|
return s:prog
|
|
|
|
endfunction
|
2016-03-10 19:56:47 -07:00
|
|
|
|
|
|
|
function! provider#ruby#Require(host) abort
|
2017-06-03 17:19:49 -07:00
|
|
|
let prog = provider#ruby#Prog()
|
2016-03-10 19:56:47 -07:00
|
|
|
let ruby_plugins = remote#host#PluginsForHost(a:host.name)
|
|
|
|
|
|
|
|
for plugin in ruby_plugins
|
2017-06-03 17:19:49 -07:00
|
|
|
let prog .= " " . shellescape(plugin.path)
|
2016-03-10 19:56:47 -07:00
|
|
|
endfor
|
|
|
|
|
2018-02-16 11:53:02 -07:00
|
|
|
return provider#Poll(prog, a:host.orig_name, '$NVIM_RUBY_LOG_FILE')
|
2016-03-10 19:56:47 -07:00
|
|
|
endfunction
|
|
|
|
|
2017-12-17 07:53:11 -07:00
|
|
|
function! provider#ruby#Call(method, args) abort
|
2016-07-02 21:45:48 -07:00
|
|
|
if s:err != ''
|
|
|
|
echoerr s:err
|
|
|
|
return
|
|
|
|
endif
|
|
|
|
|
|
|
|
if !exists('s:host')
|
|
|
|
try
|
|
|
|
let s:host = remote#host#Require('legacy-ruby-provider')
|
|
|
|
catch
|
|
|
|
let s:err = v:exception
|
|
|
|
echohl WarningMsg
|
|
|
|
echomsg v:exception
|
|
|
|
echohl None
|
|
|
|
return
|
|
|
|
endtry
|
|
|
|
endif
|
|
|
|
return call('rpcrequest', insert(insert(a:args, 'ruby_'.a:method), s:host))
|
2016-03-10 19:56:47 -07:00
|
|
|
endfunction
|
2016-07-02 21:45:48 -07:00
|
|
|
|
2018-08-08 15:47:35 -07:00
|
|
|
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
|
|
|
|
|
2016-07-02 21:45:48 -07:00
|
|
|
let s:err = ''
|
2018-08-08 15:47:35 -07:00
|
|
|
let s:prog = s:detect()
|
2016-07-02 21:45:48 -07:00
|
|
|
let s:plugin_path = expand('<sfile>:p:h') . '/script_host.rb'
|
|
|
|
|
|
|
|
if empty(s:prog)
|
2017-10-15 11:31:12 -07:00
|
|
|
let s:err = 'Cannot find the neovim RubyGem. Try :checkhealth'
|
2016-07-02 21:45:48 -07:00
|
|
|
endif
|
|
|
|
|
|
|
|
call remote#host#RegisterClone('legacy-ruby-provider', 'ruby')
|
|
|
|
call remote#host#RegisterPlugin('legacy-ruby-provider', s:plugin_path, [])
|