3 " Maintainer: Jocelyn Fiat <eiffel@djoce.net>
4 " Previous-Maintainer: David Clarke <gadicath@dishevelled.net>
5 " $Date: 2004/12/09 21:33:52 $
7 " URL: http://www.djoce.net/page/vim/
8 " Last Change: 2004 Sept 14 : removed specific value for tab (sw)
10 " Only load this indent file when no other was loaded.
11 if exists("b:did_indent")
16 setlocal indentexpr=GetEiffelIndent()
18 setlocal nosmartindent
22 setlocal indentkeys+==end,=else,=ensure,=require,=check,=loop,=until
23 setlocal indentkeys+==creation,=feature,=inherit,=class,=is,=redefine,=rename,=variant
24 setlocal indentkeys+==invariant,=do,=local,=export
27 " keywords grouped by indenting
28 let s:trust_user_indent = '\(+\)\(\s*\(--\).*\)\=$'
29 let s:relative_indent = '^\s*\(deferred\|class\|feature\|creation\|inherit\|loop\|from\|until\|if\|else\|elseif\|ensure\|require\|check\|do\|local\|invariant\|variant\|rename\|redefine\|do\|export\)\>'
30 let s:outdent = '^\s*\(else\|invariant\|variant\|do\|require\|until\|loop\|local\)\>'
31 let s:no_indent = '^\s*\(class\|feature\|creation\|inherit\)\>'
32 let s:single_dent = '^[^-]\+[[:alnum:]]\+ is\(\s*\(--\).*\)\=$'
33 let s:inheritance_dent = '\s*\(redefine\|rename\|export\)\>'
36 " Only define the function once.
37 if exists("*GetEiffelIndent")
41 function GetEiffelIndent()
43 " Eiffel Class indenting
45 " Find a non-blank line above the current line.
46 let lnum = prevnonblank(v:lnum - 1)
48 " At the start of the file use zero indent.
53 " trust the user's indenting
54 if getline(lnum) =~ s:trust_user_indent
58 " Add a 'shiftwidth' after lines that start with an indent word
59 let ind = indent(lnum)
60 if getline(lnum) =~ s:relative_indent
64 " Indent to single indent
65 if getline(v:lnum) =~ s:single_dent && getline(v:lnum) !~ s:relative_indent
66 \ && getline(v:lnum) !~ '\s*\<\(and\|or\|implies\)\>'
70 " Indent to double indent
71 if getline(v:lnum) =~ s:inheritance_dent
75 " Indent line after the first line of the function definition
76 if getline(lnum) =~ s:single_dent
80 " The following should always be at the start of a line, no indenting
81 if getline(v:lnum) =~ s:no_indent
85 " Subtract a 'shiftwidth', if this isn't the first thing after the 'is'
86 " or first thing after the 'do'
87 if getline(v:lnum) =~ s:outdent && getline(v:lnum - 1) !~ s:single_dent
88 \ && getline(v:lnum - 1) !~ '^\s*do\>'
92 " Subtract a shiftwidth for end statements
93 if getline(v:lnum) =~ '^\s*end\>'
97 " set indent of zero end statements that are at an indent of 3, this should
98 " only ever be the class's end.
99 if getline(v:lnum) =~ '^\s*end\>' && ind == &sw