3 " Maintainer: Tim Pope <vimNOSPAM@tpope.info>
4 " Info: $Id: eruby.vim,v 1.8 2007/05/12 13:38:20 vimboss Exp $
5 " URL: http://vim-ruby.rubyforge.org
6 " Anon CVS: See above site
7 " Release Coordinator: Doug Kearns <dougkearns@gmail.com>
9 if exists("b:did_indent")
13 runtime! indent/ruby.vim
17 if exists("b:eruby_subtype")
18 exe "runtime! indent/".b:eruby_subtype.".vim"
20 runtime! indent/html.vim
24 if &l:indentexpr == ''
26 let &l:indentexpr = 'cindent(v:lnum)'
28 let &l:indentexpr = 'indent(prevnonblank(v:lnum-1))'
31 let b:eruby_subtype_indentexpr = &l:indentexpr
35 setlocal indentexpr=GetErubyIndent()
36 setlocal indentkeys=o,O,*<Return>,<>>,{,},0),0],o,O,!^F,=end,=else,=elsif,=rescue,=ensure,=when
38 " Only define the function once.
39 if exists("*GetErubyIndent")
43 function! GetErubyIndent()
46 let inruby = searchpair('<%','','%>')
47 call cursor(v:lnum,vcol)
48 if inruby && getline(v:lnum) !~ '^<%'
49 let ind = GetRubyIndent()
51 exe "let ind = ".b:eruby_subtype_indentexpr
53 let lnum = prevnonblank(v:lnum-1)
54 let line = getline(lnum)
55 let cline = getline(v:lnum)
56 if cline =~# '<%\s*\%(end\|else\|\%(ensure\|rescue\|elsif\|when\).\{-\}\)\s*\%(-\=%>\|$\)'
59 if line =~# '\<do\%(\s*|[^|]*|\)\=\s*-\=%>'
61 elseif line =~# '<%\s*\%(module\|class\|def\|if\|for\|while\|until\|else\|elsif\|case\|when\|unless\|begin\|ensure\|rescue\)\>.*%>'
64 if line =~# '^\s*<%[=#]\=\s*$' && cline !~# '^\s*end\>'
67 if cline =~# '^\s*-\=%>\s*$'
73 " vim:set sw=2 sts=2 ts=8 noet ff=unix: