aboutsummaryrefslogtreecommitdiff
path: root/runtime/autoload
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/autoload')
-rw-r--r--runtime/autoload/health.vim35
-rw-r--r--runtime/autoload/provider/clipboard.vim7
-rw-r--r--runtime/autoload/provider/ruby.vim50
-rw-r--r--runtime/autoload/provider/script_host.rb8
-rw-r--r--runtime/autoload/remote/host.vim2
5 files changed, 87 insertions, 15 deletions
diff --git a/runtime/autoload/health.vim b/runtime/autoload/health.vim
index dc362577a6..0a698e6492 100644
--- a/runtime/autoload/health.vim
+++ b/runtime/autoload/health.vim
@@ -404,6 +404,39 @@ function! s:diagnose_python(version) abort
endfunction
+function! s:diagnose_ruby() abort
+ echo 'Checking: Ruby'
+ let ruby_vers = systemlist('ruby -v')[0]
+ let ruby_prog = provider#ruby#Detect()
+ let notes = []
+
+ if empty(ruby_prog)
+ let ruby_prog = 'not found'
+ let prog_vers = 'not found'
+ call add(notes, 'Suggestion: Install the neovim RubyGem using ' .
+ \ '`gem install neovim`.')
+ else
+ silent let prog_vers = systemlist(ruby_prog . ' --version')[0]
+
+ if v:shell_error
+ let prog_vers = 'outdated'
+ call add(notes, 'Suggestion: Install the latest neovim RubyGem using ' .
+ \ '`gem install neovim`.')
+ elseif s:version_cmp(prog_vers, "0.2.0") == -1
+ let prog_vers .= ' (outdated)'
+ call add(notes, 'Suggestion: Install the latest neovim RubyGem using ' .
+ \ '`gem install neovim`.')
+ endif
+ endif
+
+ echo ' Ruby Version: ' . ruby_vers
+ echo ' Host Executable: ' . ruby_prog
+ echo ' Host Version: ' . prog_vers
+
+ call s:echo_notes(notes)
+endfunction
+
+
function! health#check(bang) abort
redir => report
try
@@ -411,6 +444,8 @@ function! health#check(bang) abort
silent echo ''
silent call s:diagnose_python(3)
silent echo ''
+ silent call s:diagnose_ruby()
+ silent echo ''
silent call s:diagnose_manifest()
silent echo ''
finally
diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim
index 77bc8c781d..0f4aa78ddd 100644
--- a/runtime/autoload/provider/clipboard.vim
+++ b/runtime/autoload/provider/clipboard.vim
@@ -65,11 +65,10 @@ endif
let s:clipboard = {}
function! s:clipboard.get(reg)
- let reg = a:reg == '"' ? '+' : a:reg
- if s:selections[reg].owner > 0
- return s:selections[reg].data
+ if s:selections[a:reg].owner > 0
+ return s:selections[a:reg].data
end
- return s:try_cmd(s:paste[reg])
+ return s:try_cmd(s:paste[a:reg])
endfunction
function! s:clipboard.set(lines, regtype, reg)
diff --git a/runtime/autoload/provider/ruby.vim b/runtime/autoload/provider/ruby.vim
index aad8c09d28..e9130b98c1 100644
--- a/runtime/autoload/provider/ruby.vim
+++ b/runtime/autoload/provider/ruby.vim
@@ -1,12 +1,18 @@
" The Ruby provider helper
-if exists('s:loaded_ruby_provider')
+if exists('g:loaded_ruby_provider')
finish
endif
+let g:loaded_ruby_provider = 1
-let s:loaded_ruby_provider = 1
+function! provider#ruby#Detect() abort
+ return exepath('neovim-ruby-host')
+endfunction
+
+function! provider#ruby#Prog()
+ return s:prog
+endfunction
function! provider#ruby#Require(host) abort
- " Collect registered Ruby plugins into args
let args = []
let ruby_plugins = remote#host#PluginsForHost(a:host.name)
@@ -16,19 +22,43 @@ function! provider#ruby#Require(host) abort
try
let channel_id = rpcstart(provider#ruby#Prog(), args)
-
- if rpcrequest(channel_id, 'poll') == 'ok'
+ if rpcrequest(channel_id, 'poll') ==# 'ok'
return channel_id
endif
catch
echomsg v:throwpoint
echomsg v:exception
endtry
-
- throw remote#host#LoadErrorForHost(a:host.orig_name,
- \ '$NVIM_RUBY_LOG_FILE')
+ throw remote#host#LoadErrorForHost(a:host.orig_name, '$NVIM_RUBY_LOG_FILE')
endfunction
-function! provider#ruby#Prog() abort
- return 'neovim-ruby-host'
+function! provider#ruby#Call(method, args)
+ 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))
endfunction
+
+let s:err = ''
+let s:prog = provider#ruby#Detect()
+let s:plugin_path = expand('<sfile>:p:h') . '/script_host.rb'
+
+if empty(s:prog)
+ let s:err = 'Cannot find the neovim RubyGem. Try :CheckHealth'
+endif
+
+call remote#host#RegisterClone('legacy-ruby-provider', 'ruby')
+call remote#host#RegisterPlugin('legacy-ruby-provider', s:plugin_path, [])
diff --git a/runtime/autoload/provider/script_host.rb b/runtime/autoload/provider/script_host.rb
new file mode 100644
index 0000000000..1dade766c7
--- /dev/null
+++ b/runtime/autoload/provider/script_host.rb
@@ -0,0 +1,8 @@
+begin
+ require "neovim/ruby_provider"
+rescue LoadError
+ warn(
+ "Your neovim RubyGem is missing or out of date. " +
+ "Install the latest version using `gem install neovim`."
+ )
+end
diff --git a/runtime/autoload/remote/host.vim b/runtime/autoload/remote/host.vim
index 4ec2eeb5b7..eb5e87d7e1 100644
--- a/runtime/autoload/remote/host.vim
+++ b/runtime/autoload/remote/host.vim
@@ -121,7 +121,7 @@ endfunction
function! s:GetManifest() abort
let prefix = exists('$MYVIMRC')
\ ? $MYVIMRC
- \ : matchstr(get(split(capture('scriptnames'), '\n'), 0, ''), '\f\+$')
+ \ : matchstr(get(split(execute('scriptnames'), '\n'), 0, ''), '\f\+$')
return fnamemodify(expand(prefix, 1), ':h')
\.'/.'.fnamemodify(prefix, ':t').'-rplugin~'
endfunction