Skip to content

Commit d08059a

Browse files
authored
runtime(ruby): Update ftplugin and omni-complete (#13805)
Signed-off-by: Doug Kearns <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 0ede5e3 commit d08059a

File tree

2 files changed

+25
-26
lines changed

2 files changed

+25
-26
lines changed

runtime/autoload/rubycomplete.vim

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
" Language: Ruby
33
" Maintainer: Mark Guzman <[email protected]>
44
" URL: https://github.com/vim-ruby/vim-ruby
5-
" Release Coordinator: Doug Kearns <[email protected]>
6-
" Last Change: 2020 Apr 12
5+
" Last Change: 2023 Dec 31
76
" ----------------------------------------------------------------------------
87
"
98
" Ruby IRB/Complete author: Keiju ISHITSUKA([email protected])
@@ -490,7 +489,7 @@ class VimRubyCompletion
490489
trail = "%s%s" % [ dir, sub ]
491490
tcfg = "%sconfig" % trail
492491

493-
if File.exists?( tcfg )
492+
if File.exist?( tcfg )
494493
rails_base = trail
495494
break
496495
end
@@ -503,7 +502,7 @@ class VimRubyCompletion
503502

504503
bootfile = rails_base + "config/boot.rb"
505504
envfile = rails_base + "config/environment.rb"
506-
if File.exists?( bootfile ) && File.exists?( envfile )
505+
if File.exist?( bootfile ) && File.exist?( envfile )
507506
begin
508507
require bootfile
509508
require envfile

runtime/ftplugin/ruby.vim

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
" Language: Ruby
33
" Maintainer: Tim Pope <[email protected]>
44
" URL: https://github.com/vim-ruby/vim-ruby
5-
" Release Coordinator: Doug Kearns <[email protected]>
6-
" Last Change: 2023 Sep 1st
5+
" Last Change: 2023 Dec 31
76

87
if (exists("b:did_ftplugin"))
98
finish
@@ -60,35 +59,38 @@ if !exists('g:ruby_version_paths')
6059
let g:ruby_version_paths = {}
6160
endif
6261

62+
let s:path_split = has('win32') ? ';' : ':'
63+
6364
function! s:query_path(root) abort
64-
" Disabled by default for security reasons.
65-
if !get(g:, 'ruby_exec', get(g:, 'plugin_exec', 0))
66-
return []
65+
" Disabled by default for security reasons.
66+
if !get(g:, 'ruby_exec', get(g:, 'plugin_exec', 0)) || empty(a:root)
67+
return map(split($RUBYLIB, s:path_split), 'v:val ==# "." ? "" : v:val')
6768
endif
6869
let code = "print $:.join %q{,}"
69-
if &shell =~# 'sh' && empty(&shellxquote)
70-
let prefix = 'env PATH='.shellescape($PATH).' '
71-
else
72-
let prefix = ''
73-
endif
7470
if &shellxquote == "'"
75-
let path_check = prefix.'ruby --disable-gems -e "' . code . '"'
71+
let args = ' --disable-gems -e "' . code . '"'
7672
else
77-
let path_check = prefix."ruby --disable-gems -e '" . code . "'"
73+
let args = " --disable-gems -e '" . code . "'"
7874
endif
7975

80-
let cd = haslocaldir() ? 'lcd' : 'cd'
76+
let cd = haslocaldir() ? 'lcd' : exists(':tcd') && haslocaldir(-1) ? 'tcd' : 'cd'
8177
let cwd = fnameescape(getcwd())
8278
try
8379
exe cd fnameescape(a:root)
84-
let s:tmp_cwd = getcwd()
85-
if (fnamemodify(exepath('ruby'), ':p:h') ==# cwd
86-
\ && (index(split($PATH,has("win32")? ';' : ':'), s:tmp_cwd) == -1 || s:tmp_cwd == '.'))
87-
let path = []
80+
for dir in split($PATH, s:path_split)
81+
if dir !=# '.' && executable(dir . '/ruby') == 1
82+
let exepath = dir . '/ruby'
83+
break
84+
endif
85+
endfor
86+
if exists('l:exepath')
87+
let path = split(system(exepath . args),',')
88+
if v:shell_error
89+
let path = []
90+
endif
8891
else
89-
let path = split(system(path_check),',')
92+
let path = []
9093
endif
91-
unlet! s:tmp_cwd
9294
exe cd cwd
9395
return path
9496
finally
@@ -129,10 +131,8 @@ else
129131
if !exists('g:ruby_default_path')
130132
if has("ruby") && has("win32")
131133
ruby ::VIM::command( 'let g:ruby_default_path = split("%s",",")' % $:.join(%q{,}) )
132-
elseif executable('ruby') && !empty($HOME)
133-
let g:ruby_default_path = s:query_path($HOME)
134134
else
135-
let g:ruby_default_path = map(split($RUBYLIB,':'), 'v:val ==# "." ? "" : v:val')
135+
let g:ruby_default_path = s:query_path($HOME)
136136
endif
137137
endif
138138
let s:ruby_paths = g:ruby_default_path

0 commit comments

Comments
 (0)