update ruby.vim
This commit is contained in:
parent
53a905a53a
commit
170d00e1ab
@ -2,7 +2,6 @@
|
||||
" Language: Ruby
|
||||
" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
|
||||
" URL: https://github.com/vim-ruby/vim-ruby
|
||||
" Anon CVS: See above site
|
||||
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
|
||||
" ----------------------------------------------------------------------------
|
||||
|
||||
@ -15,7 +14,7 @@ let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
if has("gui_running") && !has("gui_win32")
|
||||
setlocal keywordprg=ri\ -T
|
||||
setlocal keywordprg=ri\ -T\ -f\ bs
|
||||
else
|
||||
setlocal keywordprg=ri
|
||||
endif
|
||||
@ -63,34 +62,72 @@ endif
|
||||
setlocal comments=:#
|
||||
setlocal commentstring=#\ %s
|
||||
|
||||
if !exists("s:ruby_path")
|
||||
if exists("g:ruby_path")
|
||||
let s:ruby_path = type(g:ruby_path) == type([]) ? join(g:ruby_path,',') : g:ruby_path
|
||||
if !exists('g:ruby_version_paths')
|
||||
let g:ruby_version_paths = {}
|
||||
endif
|
||||
|
||||
function! s:query_path(root)
|
||||
let code = "print $:.join %q{,}"
|
||||
if &shell =~# 'sh' && $PATH !~# '\s'
|
||||
let prefix = 'env PATH='.$PATH.' '
|
||||
else
|
||||
if has("ruby") && has("win32")
|
||||
ruby ::VIM::command( 'let s:ruby_paths = split("%s",",")' % $:.join(%q{,}) )
|
||||
elseif executable('ruby')
|
||||
let s:code = "print $:.join(%q{,})"
|
||||
if executable('env') && $PATH !~# '\s'
|
||||
let prefix = 'env PATH='.$PATH.' '
|
||||
else
|
||||
let prefix = ''
|
||||
endif
|
||||
if &shellxquote == "'"
|
||||
let s:ruby_paths = split(system(prefix.'ruby -e "' . s:code . '"'),',')
|
||||
else
|
||||
let s:ruby_paths = split(system(prefix."ruby -e '" . s:code . "'"),',')
|
||||
endif
|
||||
else
|
||||
let s:ruby_paths = split($RUBYLIB,':')
|
||||
endif
|
||||
let s:ruby_path = substitute(join(s:ruby_paths,","), '\%(^\|,\)\.\%(,\|$\)', ',,', '')
|
||||
if &g:path !~# '\v^\.%(,/%(usr|emx)/include)=,,$'
|
||||
let s:ruby_path = substitute(&g:path,',,$',',','') . ',' . s:ruby_path
|
||||
let prefix = ''
|
||||
endif
|
||||
if &shellxquote == "'"
|
||||
let path_check = prefix.'ruby -e "' . code . '"'
|
||||
else
|
||||
let path_check = prefix."ruby -e '" . code . "'"
|
||||
endif
|
||||
|
||||
let cd = haslocaldir() ? 'lcd' : 'cd'
|
||||
let cwd = getcwd()
|
||||
try
|
||||
exe cd fnameescape(a:root)
|
||||
let path = split(system(path_check),',')
|
||||
exe cd fnameescape(cwd)
|
||||
return path
|
||||
finally
|
||||
exe cd fnameescape(cwd)
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! s:build_path(path)
|
||||
let path = join(map(copy(a:path), 'v:val ==# "." ? "" : v:val'), ',')
|
||||
if &g:path !~# '\v^\.%(,/%(usr|emx)/include)=,,$'
|
||||
let path = substitute(&g:path,',,$',',','') . ',' . path
|
||||
endif
|
||||
return path
|
||||
endfunction
|
||||
|
||||
if !exists('b:ruby_version') && !exists('g:ruby_path') && isdirectory(expand('%:p:h'))
|
||||
let s:version_file = findfile('.ruby-version', '.;')
|
||||
if !empty(s:version_file)
|
||||
let b:ruby_version = get(readfile(s:version_file, '', 1), '')
|
||||
if !has_key(g:ruby_version_paths, b:ruby_version)
|
||||
let g:ruby_version_paths[b:ruby_version] = s:query_path(fnamemodify(s:version_file, ':p:h'))
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if exists("g:ruby_path")
|
||||
let s:ruby_path = type(g:ruby_path) == type([]) ? join(g:ruby_path, ',') : g:ruby_path
|
||||
elseif has_key(g:ruby_version_paths, get(b:, 'ruby_version', ''))
|
||||
let s:ruby_paths = g:ruby_version_paths[b:ruby_version]
|
||||
let s:ruby_path = s:build_path(s:ruby_paths)
|
||||
else
|
||||
if !exists('g:ruby_default_path')
|
||||
if has("ruby") && has("win32")
|
||||
ruby ::VIM::command( 'let g:ruby_default_path = split("%s",",")' % $:.join(%q{,}) )
|
||||
elseif executable('ruby')
|
||||
let g:ruby_default_path = s:query_path($HOME)
|
||||
else
|
||||
let g:ruby_default_path = map(split($RUBYLIB,':'), 'v:val ==# "." ? "" : v:val')
|
||||
endif
|
||||
endif
|
||||
let s:ruby_paths = g:ruby_default_path
|
||||
let s:ruby_path = s:build_path(s:ruby_paths)
|
||||
endif
|
||||
|
||||
if stridx(&l:path, s:ruby_path) == -1
|
||||
let &l:path = s:ruby_path
|
||||
endif
|
||||
@ -317,7 +354,6 @@ function! s:gf(count,map,edit) abort
|
||||
else
|
||||
let target = expand('<cfile>')
|
||||
endif
|
||||
let g:target = target
|
||||
let found = findfile(target, &path, a:count)
|
||||
if found ==# ''
|
||||
return 'norm! '.a:count.a:map
|
||||
|
Loading…
x
Reference in New Issue
Block a user