annotate runtime/indent/eiffel.vim @ 3352:de050fcc24cf v7.3.443

updated for version 7.3.443 Problem: MS-Windows: 'shcf' and 'shellxquote' defaults are not very good. Solution: Make a better guess when 'shell' is set to "cmd.exe". (Ben Fritz)
author Bram Moolenaar <bram@vim.org>
date Sun, 12 Feb 2012 23:23:31 +0100
parents 7bc41231fbc7
children dd6c2497c997
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim indent file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Language: Eiffel
26
404aac550f35 updated for version 7.0017
vimboss
parents: 7
diff changeset
3 " Maintainer: Jocelyn Fiat <eiffel@djoce.net>
404aac550f35 updated for version 7.0017
vimboss
parents: 7
diff changeset
4 " Previous-Maintainer: David Clarke <gadicath@dishevelled.net>
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 36
diff changeset
5 " $Date: 2004/12/09 21:33:52 $
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 36
diff changeset
6 " $Revision: 1.3 $
26
404aac550f35 updated for version 7.0017
vimboss
parents: 7
diff changeset
7 " URL: http://www.djoce.net/page/vim/
36
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
8 " Last Change: 2004 Sept 14 : removed specific value for tab (sw)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 " Only load this indent file when no other was loaded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 setlocal indentexpr=GetEiffelIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 setlocal nolisp
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 setlocal nosmartindent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 setlocal nocindent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 setlocal autoindent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 setlocal comments=:--
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 setlocal indentkeys+==end,=else,=ensure,=require,=check,=loop,=until
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 setlocal indentkeys+==creation,=feature,=inherit,=class,=is,=redefine,=rename,=variant
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 setlocal indentkeys+==invariant,=do,=local,=export
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 " Define some stuff
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 " keywords grouped by indenting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 let s:trust_user_indent = '\(+\)\(\s*\(--\).*\)\=$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 let s:outdent = '^\s*\(else\|invariant\|variant\|do\|require\|until\|loop\|local\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 let s:no_indent = '^\s*\(class\|feature\|creation\|inherit\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 let s:single_dent = '^[^-]\+[[:alnum:]]\+ is\(\s*\(--\).*\)\=$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 let s:inheritance_dent = '\s*\(redefine\|rename\|export\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 " Only define the function once.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 if exists("*GetEiffelIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 function GetEiffelIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 " Eiffel Class indenting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 " Find a non-blank line above the current line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 let lnum = prevnonblank(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 " At the start of the file use zero indent.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 if lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 " trust the user's indenting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 if getline(lnum) =~ s:trust_user_indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 return -1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 " Add a 'shiftwidth' after lines that start with an indent word
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 let ind = indent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 if getline(lnum) =~ s:relative_indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 let ind = ind + &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 " Indent to single indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 if getline(v:lnum) =~ s:single_dent && getline(v:lnum) !~ s:relative_indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 \ && getline(v:lnum) !~ '\s*\<\(and\|or\|implies\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 let ind = &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 " Indent to double indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 if getline(v:lnum) =~ s:inheritance_dent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 let ind = 2 * &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 " Indent line after the first line of the function definition
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 if getline(lnum) =~ s:single_dent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 let ind = ind + &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 " The following should always be at the start of a line, no indenting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 if getline(v:lnum) =~ s:no_indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 let ind = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 " Subtract a 'shiftwidth', if this isn't the first thing after the 'is'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 " or first thing after the 'do'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 if getline(v:lnum) =~ s:outdent && getline(v:lnum - 1) !~ s:single_dent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 \ && getline(v:lnum - 1) !~ '^\s*do\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 let ind = ind - &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 " Subtract a shiftwidth for end statements
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 if getline(v:lnum) =~ '^\s*end\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 let ind = ind - &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 " set indent of zero end statements that are at an indent of 3, this should
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 " only ever be the class's end.
26
404aac550f35 updated for version 7.0017
vimboss
parents: 7
diff changeset
99 if getline(v:lnum) =~ '^\s*end\>' && ind == &sw
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 let ind = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 " vim:sw=2