diff --git a/ftplugin/ruby.vim b/ftplugin/ruby/prefs.vim similarity index 99% rename from ftplugin/ruby.vim rename to ftplugin/ruby/prefs.vim index b9b2310..717e519 100644 --- a/ftplugin/ruby.vim +++ b/ftplugin/ruby/prefs.vim @@ -20,3 +20,4 @@ setlocal shiftwidth=2 setlocal expandtab "set highlight + diff --git a/ftplugin/ruby/utils.vim b/ftplugin/ruby/utils.vim new file mode 100644 index 0000000..7431759 --- /dev/null +++ b/ftplugin/ruby/utils.vim @@ -0,0 +1,24 @@ +" from https://github.com/vim-ruby/vim-ruby/wiki/VimRubySupport + +if !exists( "*RubyEndToken" ) + + function RubyEndToken() + let current_line = getline( '.' ) + let braces_at_end = '{\s*\(|\(,\|\s\|\w\)*|\s*\)\?$' + let stuff_without_do = '^\s*\(class\|if\|unless\|begin\|case\|for\|module\|while\|until\|def\)' + let with_do = 'do\s*\(|\(,\|\s\|\w\)*|\s*\)\?$' + + if match(current_line, braces_at_end) >= 0 + return "\}\O" + elseif match(current_line, stuff_without_do) >= 0 + return "\end\O" + elseif match(current_line, with_do) >= 0 + return "\end\O" + else + return "\" + endif + endfunction + +endif + +imap =RubyEndToken()