From 5d831bbb7b550e36216f0783bf70f564e07e26c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20Logerais=20=28Numericable=20-=20Ing=C3=A9nierie?= =?UTF-8?q?=20Syst=C3=A8me=29?= Date: Mon, 2 Mar 2015 12:33:41 +0100 Subject: [PATCH] Modified preferences for ruby --- ftplugin/{ruby.vim => ruby/prefs.vim} | 1 + ftplugin/ruby/utils.vim | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) rename ftplugin/{ruby.vim => ruby/prefs.vim} (99%) create mode 100644 ftplugin/ruby/utils.vim 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()