Mercurial > vim
annotate runtime/indent/eiffel.vim @ 3526:dd6c2497c997
Fix more 'cpo' issues in runtime files.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Fri, 18 May 2012 21:49:28 +0200 |
parents | 7bc41231fbc7 |
children | 9cb3a75a20b9 |
rev | line source |
---|---|
7 | 1 " Vim indent file |
2 " Language: Eiffel | |
26 | 3 " Maintainer: Jocelyn Fiat <eiffel@djoce.net> |
4 " Previous-Maintainer: David Clarke <gadicath@dishevelled.net> | |
2034 | 5 " $Date: 2004/12/09 21:33:52 $ |
6 " $Revision: 1.3 $ | |
26 | 7 " URL: http://www.djoce.net/page/vim/ |
3526
dd6c2497c997
Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
8 " Last Change: 2012 May 18 |
7 | 9 |
10 " Only load this indent file when no other was loaded. | |
11 if exists("b:did_indent") | |
12 finish | |
13 endif | |
14 let b:did_indent = 1 | |
15 | |
16 setlocal indentexpr=GetEiffelIndent() | |
17 setlocal nolisp | |
18 setlocal nosmartindent | |
19 setlocal nocindent | |
20 setlocal autoindent | |
21 setlocal comments=:-- | |
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 | |
25 | |
26 " Define some stuff | |
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\)\>' | |
34 | |
35 | |
36 " Only define the function once. | |
37 if exists("*GetEiffelIndent") | |
38 finish | |
39 endif | |
3526
dd6c2497c997
Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
40 let s:keepcpo= &cpo |
dd6c2497c997
Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
41 set cpo&vim |
7 | 42 |
43 function GetEiffelIndent() | |
44 | |
45 " Eiffel Class indenting | |
46 " | |
47 " Find a non-blank line above the current line. | |
48 let lnum = prevnonblank(v:lnum - 1) | |
49 | |
50 " At the start of the file use zero indent. | |
51 if lnum == 0 | |
52 return 0 | |
53 endif | |
54 | |
55 " trust the user's indenting | |
56 if getline(lnum) =~ s:trust_user_indent | |
57 return -1 | |
58 endif | |
59 | |
60 " Add a 'shiftwidth' after lines that start with an indent word | |
61 let ind = indent(lnum) | |
62 if getline(lnum) =~ s:relative_indent | |
63 let ind = ind + &sw | |
64 endif | |
65 | |
66 " Indent to single indent | |
67 if getline(v:lnum) =~ s:single_dent && getline(v:lnum) !~ s:relative_indent | |
68 \ && getline(v:lnum) !~ '\s*\<\(and\|or\|implies\)\>' | |
69 let ind = &sw | |
70 endif | |
71 | |
72 " Indent to double indent | |
73 if getline(v:lnum) =~ s:inheritance_dent | |
74 let ind = 2 * &sw | |
75 endif | |
76 | |
77 " Indent line after the first line of the function definition | |
78 if getline(lnum) =~ s:single_dent | |
79 let ind = ind + &sw | |
80 endif | |
81 | |
82 " The following should always be at the start of a line, no indenting | |
83 if getline(v:lnum) =~ s:no_indent | |
84 let ind = 0 | |
85 endif | |
86 | |
87 " Subtract a 'shiftwidth', if this isn't the first thing after the 'is' | |
88 " or first thing after the 'do' | |
89 if getline(v:lnum) =~ s:outdent && getline(v:lnum - 1) !~ s:single_dent | |
90 \ && getline(v:lnum - 1) !~ '^\s*do\>' | |
91 let ind = ind - &sw | |
92 endif | |
93 | |
94 " Subtract a shiftwidth for end statements | |
95 if getline(v:lnum) =~ '^\s*end\>' | |
96 let ind = ind - &sw | |
97 endif | |
98 | |
99 " set indent of zero end statements that are at an indent of 3, this should | |
100 " only ever be the class's end. | |
26 | 101 if getline(v:lnum) =~ '^\s*end\>' && ind == &sw |
7 | 102 let ind = 0 |
103 endif | |
104 | |
105 return ind | |
106 endfunction | |
107 | |
3526
dd6c2497c997
Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
108 let &cpo = s:keepcpo |
dd6c2497c997
Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
109 unlet s:keepcpo |
dd6c2497c997
Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
110 |
7 | 111 " vim:sw=2 |