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