annotate runtime/indent/ada.vim @ 1030:d4bc24e6a281 v7.0.156

updated for version 7.0-156
author vimboss
date Wed, 01 Nov 2006 17:12:57 +0000
parents 8cd729851562
children e63691e7c504
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: Ada
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 " Maintainer: Neil Bird <neil@fnxweb.com>
856
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
4 " Last Change: 2006 Apr 30
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 " Version: $Id$
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 " Look for the latest version at http://vim.sourceforge.net/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 " ToDo:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 " Verify handling of multi-line exprs. and recovery upon the final ';'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 " Correctly find comments given '"' and "" ==> " syntax.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 " Combine the two large block-indent functions into one?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 " Only load this indent file when no other was loaded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 setlocal indentexpr=GetAdaIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 setlocal indentkeys-=0{,0}
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 setlocal indentkeys+=0=~then,0=~end,0=~elsif,0=~when,0=~exception,0=~begin,0=~is,0=~record
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 " Only define the functions once.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 if exists("*GetAdaIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27
36
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
28 let s:AdaBlockStart = '^\s*\(if\>\|while\>\|else\>\|elsif\>\|loop\>\|for\>.*\<\(loop\|use\)\>\|declare\>\|begin\>\|type\>.*\<is\>[^;]*$\|\(type\>.*\)\=\<record\>\|procedure\>\|function\>\|accept\>\|do\>\|task\>\|package\>\|then\>\|when\>\|is\>\)'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 let s:AdaComment = "\\v^(\"[^\"]*\"|'.'|[^\"']){-}\\zs\\s*--.*"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31
36
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
32 " Try to find indent of the block we're in
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 " prev_indent = the previous line's indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 " prev_lnum = previous line (to start looking on)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 " blockstart = expr. that indicates a possible start of this block
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 " stop_at = if non-null, if a matching line is found, gives up!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 " No recursive previous block analysis: simply look for a valid line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 " with a lesser or equal indent than we currently (on prev_lnum) have.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 " This shouldn't work as well as it appears to with lines that are currently
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 " nowhere near the correct indent (e.g., start of line)!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 " Seems to work OK as it 'starts' with the indent of the /previous/ line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 function s:MainBlockIndent( prev_indent, prev_lnum, blockstart, stop_at )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 let lnum = a:prev_lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 let line = substitute( getline(lnum), s:AdaComment, '', '' )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 while lnum > 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 if a:stop_at != '' && line =~ '^\s*' . a:stop_at && indent(lnum) < a:prev_indent
856
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
47 return a:prev_indent
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 elseif line =~ '^\s*' . a:blockstart
856
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
49 let ind = indent(lnum)
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
50 if ind < a:prev_indent
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
51 return ind
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
52 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 let lnum = prevnonblank(lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 " Get previous non-blank/non-comment-only line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 while 1
856
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
58 let line = substitute( getline(lnum), s:AdaComment, '', '' )
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
59 if line !~ '^\s*$' && line !~ '^\s*#'
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
60 break
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
61 endif
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
62 let lnum = prevnonblank(lnum - 1)
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
63 if lnum <= 0
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
64 return a:prev_indent
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
65 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 " Fallback - just move back one
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 return a:prev_indent - &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 " Try to find indent of the block we're in (and about to complete),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 " including handling of nested blocks. Works on the 'end' of a block.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 " prev_indent = the previous line's indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 " prev_lnum = previous line (to start looking on)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 " blockstart = expr. that indicates a possible start of this block
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 " blockend = expr. that indicates a possible end of this block
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 function s:EndBlockIndent( prev_indent, prev_lnum, blockstart, blockend )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 let lnum = a:prev_lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 let line = getline(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 let ends = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 while lnum > 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 if getline(lnum) =~ '^\s*' . a:blockstart
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 let ind = indent(lnum)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
85 if ends <= 0
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
86 if ind < a:prev_indent
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 return ind
856
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
88 endif
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
89 else
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
90 let ends = ends - 1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 elseif getline(lnum) =~ '^\s*' . a:blockend
856
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
93 let ends = ends + 1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 let lnum = prevnonblank(lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 " Get previous non-blank/non-comment-only line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 while 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 let line = getline(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 let line = substitute( line, s:AdaComment, '', '' )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 if line !~ '^\s*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 break
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 let lnum = prevnonblank(lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 if lnum <= 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 return a:prev_indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 " Fallback - just move back one
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 return a:prev_indent - &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113
36
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
114 " Return indent of previous statement-start
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 " (after we've indented due to multi-line statements).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 " This time, we start searching on the line *before* the one given (which is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 " the end of a statement - we want the previous beginning).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 function s:StatementIndent( current_indent, prev_lnum )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 let lnum = a:prev_lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 while lnum > 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 let prev_lnum = lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 let lnum = prevnonblank(lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 " Get previous non-blank/non-comment-only line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 while 1
856
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
125 let line = substitute( getline(lnum), s:AdaComment, '', '' )
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
126 if line !~ '^\s*$' && line !~ '^\s*#'
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
127 break
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
128 endif
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
129 let lnum = prevnonblank(lnum - 1)
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
130 if lnum <= 0
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
131 return a:current_indent
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
132 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 " Leave indent alone if our ';' line is part of a ';'-delineated
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 " aggregate (e.g., procedure args.) or first line after a block start.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 if line =~ s:AdaBlockStart || line =~ '(\s*$'
856
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
137 return a:current_indent
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 if line !~ '[.=(]\s*$'
856
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
140 let ind = indent(prev_lnum)
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
141 if ind < a:current_indent
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
142 return ind
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
143 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 " Fallback - just use current one
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 return a:current_indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 " Find correct indent of a new line based upon what went before
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 function GetAdaIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 " Find a non-blank line above the current line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 let lnum = prevnonblank(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 let ind = indent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 let package_line = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 " Get previous non-blank/non-comment-only/non-cpp line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 while 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 let line = substitute( getline(lnum), s:AdaComment, '', '' )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 if line !~ '^\s*$' && line !~ '^\s*#'
856
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
162 break
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 let lnum = prevnonblank(lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 if lnum <= 0
856
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
166 return ind
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 " Get default indent (from prev. line)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 let ind = indent(lnum)
36
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
172 let initind = ind
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 " Now check what's on the previous line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 if line =~ s:AdaBlockStart || line =~ '(\s*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 " Check for false matches to AdaBlockStart
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 let false_match = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 if line =~ '^\s*\(procedure\|function\|package\)\>.*\<is\s*new\>'
856
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
179 " Generic instantiation
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
180 let false_match = 1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 elseif line =~ ')\s*;\s*$' || line =~ '^\([^(]*([^)]*)\)*[^(]*;\s*$'
856
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
182 " forward declaration
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
183 let false_match = 1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 " Move indent in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 if ! false_match
856
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
187 let ind = ind + &sw
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 elseif line =~ '^\s*\(case\|exception\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 " Move indent in twice (next 'when' will move back)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 let ind = ind + 2 * &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 elseif line =~ '^\s*end\s*record\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 " Move indent back to tallying 'type' preceeding the 'record'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 " Allow indent to be equal to 'end record's.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 let ind = s:MainBlockIndent( ind+&sw, lnum, 'type\>', '' )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 elseif line =~ '\(^\s*new\>.*\)\@<!)\s*[;,]\s*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 " Revert to indent of line that started this parenthesis pair
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 exe lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 exe 'normal! $F)%'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 if getline('.') =~ '^\s*('
856
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
201 " Dire layout - use previous indent (could check for AdaComment here)
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
202 let ind = indent( prevnonblank( line('.')-1 ) )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 else
856
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
204 let ind = indent('.')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 exe v:lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 elseif line =~ '[.=(]\s*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 " A statement continuation - move in one
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 let ind = ind + &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 elseif line =~ '^\s*new\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 " Multiple line generic instantiation ('package blah is\nnew thingy')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 let ind = s:StatementIndent( ind - &sw, lnum )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 elseif line =~ ';\s*$'
36
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
214 " Statement end (but not 'end' ) - try to find current statement-start indent
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 let ind = s:StatementIndent( ind, lnum )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 " Check for potential argument list on next line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 let continuation = (line =~ '[A-Za-z0-9_]\s*$')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 " Check current line; search for simplistic matching start-of-block
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 let line = getline(v:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 if line =~ '^\s*#'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 " Start of line for ada-pp
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 let ind = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 elseif continuation && line =~ '^\s*('
36
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
228 " Don't do this if we've already indented due to the previous line
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
229 if ind == initind
856
8cd729851562 updated for version 7.0g
vimboss
parents: 36
diff changeset
230 let ind = ind + &sw
36
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
231 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 elseif line =~ '^\s*\(begin\|is\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 let ind = s:MainBlockIndent( ind, lnum, '\(procedure\|function\|declare\|package\|task\)\>', 'begin\>' )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 elseif line =~ '^\s*record\>'
36
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
235 let ind = s:MainBlockIndent( ind, lnum, 'type\>\|for\>.*\<use\>', '' ) + &sw
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 elseif line =~ '^\s*\(else\|elsif\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 let ind = s:MainBlockIndent( ind, lnum, 'if\>', '' )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 elseif line =~ '^\s*when\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 " Align 'when' one /in/ from matching block start
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 let ind = s:MainBlockIndent( ind, lnum, '\(case\|exception\)\>', '' ) + &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 elseif line =~ '^\s*end\>\s*\<if\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 " End of if statements
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 let ind = s:EndBlockIndent( ind, lnum, 'if\>', 'end\>\s*\<if\>' )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 elseif line =~ '^\s*end\>\s*\<loop\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 " End of loops
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 let ind = s:EndBlockIndent( ind, lnum, '\(\(while\|for\)\>.*\)\?\<loop\>', 'end\>\s*\<loop\>' )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 elseif line =~ '^\s*end\>\s*\<record\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 " End of records
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 let ind = s:EndBlockIndent( ind, lnum, '\(type\>.*\)\=\<record\>', 'end\>\s*\<record\>' )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 elseif line =~ '^\s*end\>\s*\<procedure\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 " End of procedures
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 let ind = s:EndBlockIndent( ind, lnum, 'procedure\>.*\<is\>', 'end\>\s*\<procedure\>' )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 elseif line =~ '^\s*end\>\s*\<case\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 " End of case statement
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 let ind = s:EndBlockIndent( ind, lnum, 'case\>.*\<is\>', 'end\>\s*\<case\>' )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 elseif line =~ '^\s*end\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 " General case for end
36
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
258 let ind = s:MainBlockIndent( ind, lnum, '\(if\|while\|for\|loop\|accept\|begin\|record\|case\|exception\|package\)\>', '' )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 elseif line =~ '^\s*exception\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 let ind = s:MainBlockIndent( ind, lnum, 'begin\>', '' )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 elseif line =~ '^\s*then\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 let ind = s:MainBlockIndent( ind, lnum, 'if\>', '' )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 " vim: set sw=3 sts=3 :