Skip to content

Commit 7ff47b7

Browse files
committed
New 'path' generation
The 'path' is now simply Ruby's load path, prefixed with the global 'path' if it was set to a default value. Notably, this means the current working directory is only included if Ruby itself included it (true on 1.8, but not 1.9). Closes vim-ruby#32.
1 parent 52f01f1 commit 7ff47b7

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

ftplugin/ruby.vim

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,24 @@ setlocal commentstring=#\ %s
7171
if !exists("s:ruby_path")
7272
if exists("g:ruby_path")
7373
let s:ruby_path = g:ruby_path
74-
elseif has("ruby") && has("win32")
75-
ruby VIM::command( 'let s:ruby_path = "%s"' % $:.join(%q{,}) )
76-
let s:ruby_path = '.,' . substitute(s:ruby_path, '\%(^\|,\)\.\%(,\|$\)', ',,', '')
77-
elseif executable("ruby")
78-
let s:code = "print $:.join(%q{,})"
79-
if &shellxquote == "'"
80-
let s:ruby_path = system('ruby -e "' . s:code . '"')
74+
else
75+
if has("ruby") && has("win32")
76+
ruby VIM::command( 'let s:ruby_path = "%s"' % $:.join(%q{,}) )
77+
let s:ruby_path = substitute(s:ruby_path, '\%(^\|,\)\.\%(,\|$\)', ',,', '')
78+
elseif executable("ruby")
79+
let s:code = "print $:.join(%q{,})"
80+
if &shellxquote == "'"
81+
let s:ruby_path = system('ruby -e "' . s:code . '"')
82+
else
83+
let s:ruby_path = system("ruby -e '" . s:code . "'")
84+
endif
85+
let s:ruby_path = substitute(s:ruby_path, '\%(^\|,\)\.\%(,\|$\)', ',,', '')
8186
else
82-
let s:ruby_path = system("ruby -e '" . s:code . "'")
87+
let s:ruby_path = substitute($RUBYLIB,':',',','g')
88+
endif
89+
if &g:path !~# '\v^\.%(,/%(usr|emx)/include)=,,$'
90+
let s:ruby_path = substitute(&g:path,',,$',',','') . ',' . s:ruby_path
8391
endif
84-
let s:ruby_path = '.,' . substitute(s:ruby_path, '\%(^\|,\)\.\%(,\|$\)', ',,', '')
85-
else
86-
" If we can't call ruby to get its path, just default to using the
87-
" current directory and the directory of the current file.
88-
let s:ruby_path = ".,,"
8992
endif
9093
endif
9194

0 commit comments

Comments
 (0)