1
0
mirror of https://github.com/xlogerais/config-vim synced 2024-09-19 22:29:58 +02:00

Modified preferences for ruby

This commit is contained in:
Xavier Logerais (Numericable - Ingénierie Système) 2015-03-02 12:33:41 +01:00
parent bceb91c4f3
commit 5d831bbb7b
2 changed files with 25 additions and 0 deletions

View File

@ -20,3 +20,4 @@ setlocal shiftwidth=2
setlocal expandtab setlocal expandtab
"set highlight "set highlight

24
ftplugin/ruby/utils.vim Normal file
View File

@ -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 "\<CR>}\<C-O>O"
elseif match(current_line, stuff_without_do) >= 0
return "\<CR>end\<C-O>O"
elseif match(current_line, with_do) >= 0
return "\<CR>end\<C-O>O"
else
return "\<CR>"
endif
endfunction
endif
imap <buffer> <CR> <C-R>=RubyEndToken()<CR>