From 9964e468c0209f6b8286e0b08109817c845a3079 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 5 May 2007 17:54:07 +0000 Subject: updated for version 7.1a --- runtime/indent/eruby.vim | 51 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) (limited to 'runtime/indent/eruby.vim') diff --git a/runtime/indent/eruby.vim b/runtime/indent/eruby.vim index ab950b6599..d621bfa08b 100644 --- a/runtime/indent/eruby.vim +++ b/runtime/indent/eruby.vim @@ -1,16 +1,59 @@ " Vim indent file -" Language: Ruby -" Maintainer: Doug Kearns +" Language: eRuby +" Maintainer: Tim Pope " Info: $Id$ " URL: http://vim-ruby.rubyforge.org " Anon CVS: See above site " Release Coordinator: Doug Kearns -" Only load this indent file when no other was loaded. if exists("b:did_indent") finish endif +runtime! indent/ruby.vim +unlet! b:did_indent + runtime! indent/html.vim +unlet! b:did_indent + +let b:did_indent = 1 + +setlocal indentexpr=GetErubyIndent(v:lnum) +setlocal indentkeys=o,O,*,<>>,{,},0),0],o,O,!^F,=end,=else,=elsif,=rescue,=ensure,=when + +" Only define the function once. +if exists("*GetErubyIndent") + finish +endif + +function! GetErubyIndent(lnum) + let vcol = col('.') + call cursor(a:lnum,1) + let inruby = searchpair('<%','','%>') + call cursor(a:lnum,vcol) + if inruby && getline(a:lnum) !~ '^<%' + let ind = GetRubyIndent() + else + let ind = HtmlIndentGet(a:lnum) + endif + let lnum = prevnonblank(a:lnum-1) + let line = getline(lnum) + let cline = getline(a:lnum) + if cline =~# '<%\s*\%(end\|else\|\%(ensure\|rescue\|elsif\|when\).\{-\}\)\s*\%(-\=%>\|$\)' + let ind = ind - &sw + endif + if line =~# '\' + let ind = ind + &sw + elseif line =~# '<%\s*\%(module\|class\|def\|if\|for\|while\|until\|else\|elsif\|case\|when\|unless\|begin\|ensure\|rescue\)\>.*%>' + let ind = ind + &sw + endif + if line =~# '^\s*<%[=#]\=\s*$' && cline !~# '^\s*end\>' + let ind = ind + &sw + endif + if cline =~# '^\s*-\=%>\s*$' + let ind = ind - &sw + endif + return ind +endfunction -" vim: nowrap sw=2 sts=2 ts=8 ff=unix: +" vim:set sw=2 sts=2 ts=8 noet ff=unix: -- cgit v1.2.3