changeset 34050:9a90c2cf96ee

runtime(ruby): Update ftplugin and omni-complete (#13805) Commit: https://github.com/vim/vim/commit/d08059ab48b822a25060b8a486085371ddeebcf7 Author: dkearns <dougkearns@gmail.com> Date: Tue Jan 2 04:58:57 2024 +1100 runtime(ruby): Update ftplugin and omni-complete (https://github.com/vim/vim/issues/13805) Signed-off-by: Doug Kearns <dougkearns@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Mon, 01 Jan 2024 19:00:07 +0100
parents 7dcfd6c96ccc
children f96f16107d61
files runtime/autoload/rubycomplete.vim runtime/ftplugin/ruby.vim
diffstat 2 files changed, 26 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/autoload/rubycomplete.vim
+++ b/runtime/autoload/rubycomplete.vim
@@ -2,8 +2,7 @@
 " Language:		Ruby
 " Maintainer:		Mark Guzman <segfault@hasno.info>
 " URL:			https://github.com/vim-ruby/vim-ruby
-" Release Coordinator:	Doug Kearns <dougkearns@gmail.com>
-" Last Change:		2020 Apr 12
+" Last Change:		2023 Dec 31
 " ----------------------------------------------------------------------------
 "
 " Ruby IRB/Complete author: Keiju ISHITSUKA(keiju@ishitsuka.com)
@@ -490,7 +489,7 @@ class VimRubyCompletion
         trail = "%s%s" % [ dir, sub ]
         tcfg = "%sconfig" % trail
 
-        if File.exists?( tcfg )
+        if File.exist?( tcfg )
           rails_base = trail
           break
         end
@@ -503,7 +502,7 @@ class VimRubyCompletion
 
     bootfile = rails_base + "config/boot.rb"
     envfile = rails_base + "config/environment.rb"
-    if File.exists?( bootfile ) && File.exists?( envfile )
+    if File.exist?( bootfile ) && File.exist?( envfile )
       begin
         require bootfile
         require envfile
--- a/runtime/ftplugin/ruby.vim
+++ b/runtime/ftplugin/ruby.vim
@@ -2,8 +2,7 @@
 " Language:		Ruby
 " Maintainer:		Tim Pope <vimNOSPAM@tpope.org>
 " URL:			https://github.com/vim-ruby/vim-ruby
-" Release Coordinator:	Doug Kearns <dougkearns@gmail.com>
-" Last Change:		2023 Sep 1st
+" Last Change:		2023 Dec 31
 
 if (exists("b:did_ftplugin"))
   finish
@@ -60,35 +59,38 @@ if !exists('g:ruby_version_paths')
   let g:ruby_version_paths = {}
 endif
 
+let s:path_split = has('win32') ? ';' : ':'
+
 function! s:query_path(root) abort
-  " Disabled by default for security reasons.  
-  if !get(g:, 'ruby_exec', get(g:, 'plugin_exec', 0))
-    return []
+  " Disabled by default for security reasons.
+  if !get(g:, 'ruby_exec', get(g:, 'plugin_exec', 0)) || empty(a:root)
+    return map(split($RUBYLIB, s:path_split), 'v:val ==# "." ? "" : v:val')
   endif
   let code = "print $:.join %q{,}"
-  if &shell =~# 'sh' && empty(&shellxquote)
-    let prefix = 'env PATH='.shellescape($PATH).' '
+  if &shellxquote == "'"
+    let args = ' --disable-gems -e "' . code . '"'
   else
-    let prefix = ''
-  endif
-  if &shellxquote == "'"
-    let path_check = prefix.'ruby --disable-gems -e "' . code . '"'
-  else
-    let path_check = prefix."ruby --disable-gems -e '" . code . "'"
+    let args = " --disable-gems -e '" . code . "'"
   endif
 
-  let cd = haslocaldir() ? 'lcd' : 'cd'
+  let cd = haslocaldir() ? 'lcd' : exists(':tcd') && haslocaldir(-1) ? 'tcd' : 'cd'
   let cwd = fnameescape(getcwd())
   try
     exe cd fnameescape(a:root)
-    let s:tmp_cwd = getcwd()
-    if (fnamemodify(exepath('ruby'), ':p:h') ==# cwd
-          \ && (index(split($PATH,has("win32")? ';' : ':'), s:tmp_cwd) == -1 || s:tmp_cwd == '.'))
+    for dir in split($PATH, s:path_split)
+      if dir !=# '.' && executable(dir . '/ruby') == 1
+	let exepath = dir . '/ruby'
+	break
+      endif
+    endfor
+    if exists('l:exepath')
+      let path = split(system(exepath . args),',')
+      if v:shell_error
+	let path = []
+      endif
+    else
       let path = []
-    else
-      let path = split(system(path_check),',')
     endif
-    unlet! s:tmp_cwd
     exe cd cwd
     return path
   finally
@@ -129,10 +131,8 @@ 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') && !empty($HOME)
+    else
       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