diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2019-11-12 21:56:06 +0100 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2019-11-12 21:56:06 +0100 |
commit | 0c79dd3e73e8e09b73d4a5d20bf470a3f6f715f2 (patch) | |
tree | 5b5e45e53e9ecafa6c182c8ce7e0266e34388e4d /ftplugin/ruby.vim | |
parent | 4e95df7c7e12cb76e781f2dacf1c07f8984cce58 (diff) | |
download | vim-polyglot-0c79dd3e73e8e09b73d4a5d20bf470a3f6f715f2.tar.gz vim-polyglot-0c79dd3e73e8e09b73d4a5d20bf470a3f6f715f2.zip |
Update
Diffstat (limited to 'ftplugin/ruby.vim')
-rw-r--r-- | ftplugin/ruby.vim | 10 |
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 |