summaryrefslogtreecommitdiffstats
path: root/ftplugin/ruby.vim
diff options
context:
space:
mode:
Diffstat (limited to 'ftplugin/ruby.vim')
-rw-r--r--ftplugin/ruby.vim10
1 files changed, 6 insertions, 4 deletions
diff --git a/ftplugin/ruby.vim b/ftplugin/ruby.vim
index 9abce9f9..9c9289b1 100644
--- a/ftplugin/ruby.vim
+++ b/ftplugin/ruby.vim
@@ -374,7 +374,6 @@ function! RubyCursorFile() abort
endtry
let pre = matchstr(strpart(getline('.'), 0, col('.')-1), '.*\f\@<!')
let post = matchstr(strpart(getline('.'), col('.')), '\f\@!.*')
- let ext = getline('.') =~# '^\s*\%(require\%(_relative\)\=\|autoload\)\>' && cfile !~# '\.rb$' ? '.rb' : ''
if s:synid() ==# hlID('rubyConstant')
let cfile = substitute(cfile,'\.\w\+[?!=]\=$','','')
let cfile = substitute(cfile,'^::','','')
@@ -383,12 +382,15 @@ function! RubyCursorFile() abort
let cfile = substitute(cfile,'\(\l\|\d\)\(\u\)','\1_\2', 'g')
return tolower(cfile) . '.rb'
elseif getline('.') =~# '^\s*require_relative\s*\(["'']\).*\1\s*$'
- let cfile = expand('%:p:h') . '/' . matchstr(getline('.'),'\(["'']\)\zs.\{-\}\ze\1') . ext
+ let cfile = expand('%:p:h') . '/' . matchstr(getline('.'),'\(["'']\)\zs.\{-\}\ze\1')
+ let cfile .= cfile !~# '\.rb$' ? '.rb' : ''
elseif getline('.') =~# '^\s*\%(require[( ]\|load[( ]\|autoload[( ]:\w\+,\)\s*\%(::\)\=File\.expand_path(\(["'']\)\.\./.*\1,\s*__FILE__)\s*$'
let target = matchstr(getline('.'),'\(["'']\)\.\.\zs/.\{-\}\ze\1')
- let cfile = expand('%:p:h') . target . ext
+ let cfile = expand('%:p:h') . target
+ let cfile .= cfile !~# '\.rb$' ? '.rb' : ''
elseif getline('.') =~# '^\s*\%(require \|load \|autoload :\w\+,\)\s*\(["'']\).*\1\s*$'
- let cfile = matchstr(getline('.'),'\(["'']\)\zs.\{-\}\ze\1') . ext
+ let cfile = matchstr(getline('.'),'\(["'']\)\zs.\{-\}\ze\1')
+ let cfile .= cfile !~# '\.rb$' ? '.rb' : ''
elseif pre.post =~# '\<File.expand_path[( ].*[''"]\{2\}, *__FILE__\>' && cfile =~# '^\.\.'
let cfile = expand('%:p:h') . strpart(cfile, 2)
else