blob: b01d1156e9acb66ae8aff920f67d982840f73699 [file] [log] [blame]
Bram Moolenaar280f1262006-01-30 00:14:18 +00001" VHDL indent ('93 syntax)
Bram Moolenaar51156d52006-01-26 22:17:47 +00002" Language: VHDL
3" Maintainer: Gerald Lai <laigera+vim?gmail.com>
Bram Moolenaar01164a62017-11-02 22:58:42 +01004" Version: 1.62
5" Last Change: 2017 Oct 17
dkearns0382f052023-08-29 05:32:59 +10006" 2023 Aug 28 by Vim Project (undo_indent)
Bram Moolenaar280f1262006-01-30 00:14:18 +00007" URL: http://www.vim.org/scripts/script.php?script_id=1450
Bram Moolenaar51156d52006-01-26 22:17:47 +00008
9" only load this indent file when no other was loaded
10if exists("b:did_indent")
11 finish
12endif
13let b:did_indent = 1
14
15" setup indent options for local VHDL buffer
16setlocal indentexpr=GetVHDLindent()
Bram Moolenaar9964e462007-05-05 17:54:07 +000017setlocal indentkeys=!^F,o,O,0(,0)
18setlocal indentkeys+==~begin,=~end\ ,=~end\ ,=~is,=~select,=~when
Bram Moolenaar51156d52006-01-26 22:17:47 +000019setlocal indentkeys+==~if,=~then,=~elsif,=~else
Bram Moolenaar9964e462007-05-05 17:54:07 +000020setlocal indentkeys+==~case,=~loop,=~for,=~generate,=~record,=~units,=~process,=~block,=~function,=~component,=~procedure
21setlocal indentkeys+==~architecture,=~configuration,=~entity,=~package
Bram Moolenaar51156d52006-01-26 22:17:47 +000022
dkearns0382f052023-08-29 05:32:59 +100023let b:undo_indent = "setlocal indentexpr< indentkeys<"
24
Bram Moolenaar51156d52006-01-26 22:17:47 +000025" constants
26" not a comment
27let s:NC = '\%(--.*\)\@<!'
28" end of string
29let s:ES = '\s*\%(--.*\)\=$'
30" no "end" keyword in front
31let s:NE = '\%(\<end\s\+\)\@<!'
32
Bram Moolenaar9964e462007-05-05 17:54:07 +000033" option to disable alignment of generic/port mappings
Bram Moolenaara7241f52008-06-24 20:39:31 +000034if !exists("g:vhdl_indent_genportmap")
35 let g:vhdl_indent_genportmap = 1
Bram Moolenaar9964e462007-05-05 17:54:07 +000036endif
37
38" option to disable alignment of right-hand side assignment "<=" statements
Bram Moolenaara7241f52008-06-24 20:39:31 +000039if !exists("g:vhdl_indent_rhsassign")
40 let g:vhdl_indent_rhsassign = 1
Bram Moolenaar9964e462007-05-05 17:54:07 +000041endif
42
Bram Moolenaar51156d52006-01-26 22:17:47 +000043" only define indent function once
44if exists("*GetVHDLindent")
45 finish
46endif
47
48function GetVHDLindent()
49 " store current line & string
50 let curn = v:lnum
51 let curs = getline(curn)
52
53 " find previous line that is not a comment
54 let prevn = prevnonblank(curn - 1)
55 let prevs = getline(prevn)
56 while prevn > 0 && prevs =~ '^\s*--'
57 let prevn = prevnonblank(prevn - 1)
58 let prevs = getline(prevn)
59 endwhile
Bram Moolenaara7241f52008-06-24 20:39:31 +000060 let prevs_noi = substitute(prevs, '^\s*', '', '')
Bram Moolenaar51156d52006-01-26 22:17:47 +000061
62 " default indent starts as previous non-comment line's indent
63 let ind = prevn > 0 ? indent(prevn) : 0
64 " backup default
65 let ind2 = ind
66
Bram Moolenaar280f1262006-01-30 00:14:18 +000067 " indent: special; kill string so it would not affect other filters
68 " keywords: "report" + string
69 " where: anywhere in current or previous line
70 let s0 = s:NC.'\<report\>\s*".*"'
71 if curs =~? s0
72 let curs = ""
73 endif
74 if prevs =~? s0
75 let prevs = ""
76 endif
77
Bram Moolenaar51156d52006-01-26 22:17:47 +000078 " indent: previous line's comment position, otherwise follow next non-comment line if possible
79 " keyword: "--"
80 " where: start of current line
81 if curs =~ '^\s*--'
82 let pn = curn - 1
83 let ps = getline(pn)
Bram Moolenaara7241f52008-06-24 20:39:31 +000084 if curs =~ '^\s*--\s' && ps =~ '--'
85 return indent(pn) + stridx(substitute(ps, '^\s*', '', ''), '--')
Bram Moolenaar51156d52006-01-26 22:17:47 +000086 else
87 " find nextnonblank line that is not a comment
88 let nn = nextnonblank(curn + 1)
89 let ns = getline(nn)
90 while nn > 0 && ns =~ '^\s*--'
91 let nn = nextnonblank(nn + 1)
92 let ns = getline(nn)
93 endwhile
94 let n = indent(nn)
95 return n != -1 ? n : ind
96 endif
97 endif
98
99 " ****************************************************************************************
100 " indent: align generic variables & port names
Bram Moolenaar15146672011-10-20 22:22:38 +0200101 " keywords: "procedure" + name, "generic", "map", "port" + "(", provided current line is part of mapping
Bram Moolenaar51156d52006-01-26 22:17:47 +0000102 " where: anywhere in previous 2 lines
103 " find following previous non-comment line
104 let pn = prevnonblank(prevn - 1)
105 let ps = getline(pn)
106 while pn > 0 && ps =~ '^\s*--'
107 let pn = prevnonblank(pn - 1)
108 let ps = getline(pn)
109 endwhile
Bram Moolenaar82af8712016-06-04 20:20:29 +0200110 if (curs =~ '^\s*)' || curs =~? '^\s*\%(\<\%(procedure\|generic\|map\|port\)\>.*\)\@<!\w\+\s*\w*\s*\((.*)\)*\s*\%(=>\s*\S\+\|:[^=]\@=\s*\%(\%(in\|out\|inout\|buffer\|linkage\)\>\|\s\+\)\)') && (prevs =~? s:NC.'\<\%(procedure\s\+\S\+\|generic\|map\|port\)\s*(\%(\s*\w\)\=' || (ps =~? s:NC.'\<\%(procedure\|generic\|map\|port\)'.s:ES && prevs =~ '^\s*('))
Bram Moolenaar51156d52006-01-26 22:17:47 +0000111 " align closing ")" with opening "("
112 if curs =~ '^\s*)'
Bram Moolenaara7241f52008-06-24 20:39:31 +0000113 return ind2 + stridx(prevs_noi, '(')
Bram Moolenaar51156d52006-01-26 22:17:47 +0000114 endif
Bram Moolenaara7241f52008-06-24 20:39:31 +0000115 let m = matchend(prevs_noi, '(\s*\ze\w')
Bram Moolenaar51156d52006-01-26 22:17:47 +0000116 if m != -1
Bram Moolenaara7241f52008-06-24 20:39:31 +0000117 return ind2 + m
Bram Moolenaar51156d52006-01-26 22:17:47 +0000118 else
Bram Moolenaara7241f52008-06-24 20:39:31 +0000119 if g:vhdl_indent_genportmap
Bram Moolenaar3ec574f2017-06-13 18:12:01 +0200120 return ind2 + stridx(prevs_noi, '(') + shiftwidth()
Bram Moolenaar9964e462007-05-05 17:54:07 +0000121 else
Bram Moolenaar3ec574f2017-06-13 18:12:01 +0200122 return ind2 + shiftwidth()
Bram Moolenaar9964e462007-05-05 17:54:07 +0000123 endif
Bram Moolenaar51156d52006-01-26 22:17:47 +0000124 endif
125 endif
126
127 " indent: align conditional/select statement
Bram Moolenaar280f1262006-01-30 00:14:18 +0000128 " keywords: variable + "<=" without ";" ending
129 " where: start of previous line
130 if prevs =~? '^\s*\S\+\s*<=[^;]*'.s:ES
Bram Moolenaara7241f52008-06-24 20:39:31 +0000131 if g:vhdl_indent_rhsassign
132 return ind2 + matchend(prevs_noi, '<=\s*\ze.')
Bram Moolenaar9964e462007-05-05 17:54:07 +0000133 else
Bram Moolenaar3ec574f2017-06-13 18:12:01 +0200134 return ind2 + shiftwidth()
Bram Moolenaar9964e462007-05-05 17:54:07 +0000135 endif
Bram Moolenaar51156d52006-01-26 22:17:47 +0000136 endif
137
138 " indent: backtrace previous non-comment lines for next smaller or equal size indent
139 " keywords: "end" + "record", "units"
140 " where: start of previous line
141 " keyword: ")"
142 " where: start of previous line
143 " keyword: without "<=" + ";" ending
144 " where: anywhere in previous line
145 " keyword: "=>" + ")" ending, provided current line does not begin with ")"
146 " where: anywhere in previous line
147 " _note_: indent allowed to leave this filter
148 let m = 0
149 if prevs =~? '^\s*end\s\+\%(record\|units\)\>'
150 let m = 3
151 elseif prevs =~ '^\s*)'
152 let m = 1
153 elseif prevs =~ s:NC.'\%(<=.*\)\@<!;'.s:ES || (curs !~ '^\s*)' && prevs =~ s:NC.'=>.*'.s:NC.')'.s:ES)
154 let m = 2
155 endif
156
157 if m > 0
158 let pn = prevnonblank(prevn - 1)
159 let ps = getline(pn)
160 while pn > 0
161 let t = indent(pn)
Bram Moolenaarb2c03502010-07-02 20:20:09 +0200162 if ps !~ '^\s*--' && (t < ind || (t == ind && m == 3))
Bram Moolenaar51156d52006-01-26 22:17:47 +0000163 " make sure one of these is true
Bram Moolenaar280f1262006-01-30 00:14:18 +0000164 " keywords: variable + "<=" without ";" ending
165 " where: start of previous non-comment line
Bram Moolenaar15146672011-10-20 22:22:38 +0200166 " keywords: "procedure", "generic", "map", "port"
Bram Moolenaar51156d52006-01-26 22:17:47 +0000167 " where: anywhere in previous non-comment line
168 " keyword: "("
169 " where: start of previous non-comment line
Bram Moolenaar280f1262006-01-30 00:14:18 +0000170 if m < 3 && ps !~? '^\s*\S\+\s*<=[^;]*'.s:ES
Bram Moolenaar15146672011-10-20 22:22:38 +0200171 if ps =~? s:NC.'\<\%(procedure\|generic\|map\|port\)\>' || ps =~ '^\s*('
Bram Moolenaar51156d52006-01-26 22:17:47 +0000172 let ind = t
173 endif
174 break
175 endif
176 let ind = t
177 if m > 1
178 " find following previous non-comment line
179 let ppn = prevnonblank(pn - 1)
180 let pps = getline(ppn)
181 while ppn > 0 && pps =~ '^\s*--'
182 let ppn = prevnonblank(ppn - 1)
183 let pps = getline(ppn)
184 endwhile
185 " indent: follow
186 " keyword: "select"
187 " where: end of following previous non-comment line
188 " keyword: "type"
189 " where: start of following previous non-comment line
190 if m == 2
191 let s1 = s:NC.'\<select'.s:ES
192 if ps !~? s1 && pps =~? s1
193 let ind = indent(ppn)
194 endif
195 elseif m == 3
196 let s1 = '^\s*type\>'
197 if ps !~? s1 && pps =~? s1
198 let ind = indent(ppn)
199 endif
200 endif
201 endif
202 break
203 endif
204 let pn = prevnonblank(pn - 1)
205 let ps = getline(pn)
206 endwhile
207 endif
208
209 " indent: follow indent of previous opening statement, otherwise -sw
210 " keyword: "begin"
211 " where: anywhere in current line
212 if curs =~? s:NC.'\<begin\>'
Bram Moolenaar51156d52006-01-26 22:17:47 +0000213 " find previous opening statement of
214 " keywords: "architecture", "block", "entity", "function", "generate", "procedure", "process"
215 let s2 = s:NC.s:NE.'\<\%(architecture\|block\|entity\|function\|generate\|procedure\|process\)\>'
Bram Moolenaar15146672011-10-20 22:22:38 +0200216
217 let pn = prevnonblank(curn - 1)
218 let ps = getline(pn)
219 while pn > 0 && (ps =~ '^\s*--' || ps !~? s2)
220 let pn = prevnonblank(pn - 1)
221 let ps = getline(pn)
222
223 if (ps =~? s:NC.'\<begin\>')
Bram Moolenaar3ec574f2017-06-13 18:12:01 +0200224 return indent(pn) - shiftwidth()
Bram Moolenaar15146672011-10-20 22:22:38 +0200225 endif
226 endwhile
227
228 if (pn == 0)
Bram Moolenaar3ec574f2017-06-13 18:12:01 +0200229 return ind - shiftwidth()
Bram Moolenaar15146672011-10-20 22:22:38 +0200230 else
231 return indent(pn)
Bram Moolenaar51156d52006-01-26 22:17:47 +0000232 endif
Bram Moolenaar51156d52006-01-26 22:17:47 +0000233 endif
234
235 " indent: +sw if previous line is previous opening statement
236 " keywords: "record", "units"
237 " where: anywhere in current line
238 if curs =~? s:NC.s:NE.'\<\%(record\|units\)\>'
239 " find previous opening statement of
240 " keyword: "type"
241 let s3 = s:NC.s:NE.'\<type\>'
242 if curs !~? s3.'.*'.s:NC.'\<\%(record\|units\)\>.*'.s:ES && prevs =~? s3
Bram Moolenaar3ec574f2017-06-13 18:12:01 +0200243 let ind = ind + shiftwidth()
Bram Moolenaar51156d52006-01-26 22:17:47 +0000244 endif
245 return ind
246 endif
247
248 " ****************************************************************************************
249 " indent: 0
250 " keywords: "architecture", "configuration", "entity", "library", "package"
251 " where: start of current line
252 if curs =~? '^\s*\%(architecture\|configuration\|entity\|library\|package\)\>'
253 return 0
254 endif
255
Bram Moolenaar280f1262006-01-30 00:14:18 +0000256 " indent: maintain indent of previous opening statement
Bram Moolenaar51156d52006-01-26 22:17:47 +0000257 " keyword: "is"
258 " where: start of current line
259 " find previous opening statement of
260 " keywords: "architecture", "block", "configuration", "entity", "function", "package", "procedure", "process", "type"
261 if curs =~? '^\s*\<is\>' && prevs =~? s:NC.s:NE.'\<\%(architecture\|block\|configuration\|entity\|function\|package\|procedure\|process\|type\)\>'
Bram Moolenaar280f1262006-01-30 00:14:18 +0000262 return ind2
Bram Moolenaar51156d52006-01-26 22:17:47 +0000263 endif
264
Bram Moolenaar280f1262006-01-30 00:14:18 +0000265 " indent: maintain indent of previous opening statement
Bram Moolenaar51156d52006-01-26 22:17:47 +0000266 " keyword: "then"
267 " where: start of current line
268 " find previous opening statement of
269 " keywords: "elsif", "if"
Bram Moolenaarb8a7b562006-02-01 21:47:16 +0000270 if curs =~? '^\s*\<then\>' && prevs =~? s:NC.'\%(\<elsif\>\|'.s:NE.'\<if\>\)'
Bram Moolenaar280f1262006-01-30 00:14:18 +0000271 return ind2
Bram Moolenaar51156d52006-01-26 22:17:47 +0000272 endif
273
Bram Moolenaar280f1262006-01-30 00:14:18 +0000274 " indent: maintain indent of previous opening statement
Bram Moolenaar51156d52006-01-26 22:17:47 +0000275 " keyword: "generate"
276 " where: start of current line
277 " find previous opening statement of
278 " keywords: "for", "if"
Bram Moolenaar9964e462007-05-05 17:54:07 +0000279 if curs =~? '^\s*\<generate\>' && prevs =~? s:NC.s:NE.'\%(\%(\<wait\s\+\)\@<!\<for\|\<if\)\>'
Bram Moolenaar280f1262006-01-30 00:14:18 +0000280 return ind2
Bram Moolenaar51156d52006-01-26 22:17:47 +0000281 endif
282
283 " indent: +sw
Bram Moolenaar9964e462007-05-05 17:54:07 +0000284 " keywords: "block", "process"
285 " removed: "begin", "case", "elsif", "if", "loop", "record", "units", "while"
Bram Moolenaar51156d52006-01-26 22:17:47 +0000286 " where: anywhere in previous line
Bram Moolenaar9964e462007-05-05 17:54:07 +0000287 if prevs =~? s:NC.s:NE.'\<\%(block\|process\)\>'
Bram Moolenaar3ec574f2017-06-13 18:12:01 +0200288 return ind + shiftwidth()
Bram Moolenaar51156d52006-01-26 22:17:47 +0000289 endif
290
291 " indent: +sw
Bram Moolenaar9964e462007-05-05 17:54:07 +0000292 " keywords: "architecture", "configuration", "entity", "package"
293 " removed: "component", "for", "when", "with"
Bram Moolenaar51156d52006-01-26 22:17:47 +0000294 " where: start of previous line
Bram Moolenaar9964e462007-05-05 17:54:07 +0000295 if prevs =~? '^\s*\%(architecture\|configuration\|entity\|package\)\>'
Bram Moolenaar3ec574f2017-06-13 18:12:01 +0200296 return ind + shiftwidth()
Bram Moolenaar51156d52006-01-26 22:17:47 +0000297 endif
298
299 " indent: +sw
Bram Moolenaar9964e462007-05-05 17:54:07 +0000300 " keyword: "select"
301 " removed: "generate", "is", "=>"
Bram Moolenaar51156d52006-01-26 22:17:47 +0000302 " where: end of previous line
Bram Moolenaar9964e462007-05-05 17:54:07 +0000303 if prevs =~? s:NC.'\<select'.s:ES
Bram Moolenaar3ec574f2017-06-13 18:12:01 +0200304 return ind + shiftwidth()
Bram Moolenaar51156d52006-01-26 22:17:47 +0000305 endif
306
307 " indent: +sw
Bram Moolenaar9964e462007-05-05 17:54:07 +0000308 " keyword: "begin", "loop", "record", "units"
309 " where: anywhere in previous line
310 " keyword: "component", "else", "for"
Bram Moolenaarb8a7b562006-02-01 21:47:16 +0000311 " where: start of previous line
Bram Moolenaar9964e462007-05-05 17:54:07 +0000312 " keyword: "generate", "is", "then", "=>"
Bram Moolenaar51156d52006-01-26 22:17:47 +0000313 " where: end of previous line
314 " _note_: indent allowed to leave this filter
Bram Moolenaar9964e462007-05-05 17:54:07 +0000315 if prevs =~? s:NC.'\%(\<begin\>\|'.s:NE.'\<\%(loop\|record\|units\)\>\)' || prevs =~? '^\s*\%(component\|else\|for\)\>' || prevs =~? s:NC.'\%('.s:NE.'\<generate\|\<\%(is\|then\)\|=>\)'.s:ES
Bram Moolenaar3ec574f2017-06-13 18:12:01 +0200316 let ind = ind + shiftwidth()
Bram Moolenaar51156d52006-01-26 22:17:47 +0000317 endif
318
319 " ****************************************************************************************
Bram Moolenaarb8a7b562006-02-01 21:47:16 +0000320 " indent: -sw
Bram Moolenaar9964e462007-05-05 17:54:07 +0000321 " keywords: "when", provided previous line does not begin with "when", does not end with "is"
Bram Moolenaar51156d52006-01-26 22:17:47 +0000322 " where: start of current line
323 let s4 = '^\s*when\>'
Bram Moolenaarb8a7b562006-02-01 21:47:16 +0000324 if curs =~? s4
Bram Moolenaar9964e462007-05-05 17:54:07 +0000325 if prevs =~? s:NC.'\<is'.s:ES
326 return ind
327 elseif prevs !~? s4
Bram Moolenaar3ec574f2017-06-13 18:12:01 +0200328 return ind - shiftwidth()
Bram Moolenaarb8a7b562006-02-01 21:47:16 +0000329 else
330 return ind2
331 endif
Bram Moolenaar51156d52006-01-26 22:17:47 +0000332 endif
333
334 " indent: -sw
Bram Moolenaar9964e462007-05-05 17:54:07 +0000335 " keywords: "else", "elsif", "end" + "block", "for", "function", "generate", "if", "loop", "procedure", "process", "record", "units"
Bram Moolenaar51156d52006-01-26 22:17:47 +0000336 " where: start of current line
Bram Moolenaar15146672011-10-20 22:22:38 +0200337 let s5 = 'block\|for\|function\|generate\|if\|loop\|procedure\|process\|record\|units'
338 if curs =~? '^\s*\%(else\|elsif\|end\s\+\%('.s5.'\)\)\>'
339 if prevs =~? '^\s*\%(elsif\|'.s5.'\)'
340 return ind
341 else
Bram Moolenaar3ec574f2017-06-13 18:12:01 +0200342 return ind - shiftwidth()
Bram Moolenaar15146672011-10-20 22:22:38 +0200343 endif
Bram Moolenaar51156d52006-01-26 22:17:47 +0000344 endif
345
Bram Moolenaar280f1262006-01-30 00:14:18 +0000346 " indent: backtrace previous non-comment lines
347 " keyword: "end" + "case", "component"
Bram Moolenaar51156d52006-01-26 22:17:47 +0000348 " where: start of current line
Bram Moolenaar280f1262006-01-30 00:14:18 +0000349 let m = 0
Bram Moolenaar51156d52006-01-26 22:17:47 +0000350 if curs =~? '^\s*end\s\+case\>'
Bram Moolenaar280f1262006-01-30 00:14:18 +0000351 let m = 1
352 elseif curs =~? '^\s*end\s\+component\>'
353 let m = 2
354 endif
355
356 if m > 0
Bram Moolenaar51156d52006-01-26 22:17:47 +0000357 " find following previous non-comment line
358 let pn = prevn
359 let ps = getline(pn)
360 while pn > 0
361 if ps !~ '^\s*--'
Bram Moolenaar280f1262006-01-30 00:14:18 +0000362 "indent: -2sw
363 "keywords: "end" + "case"
364 "where: start of previous non-comment line
365 "indent: -sw
366 "keywords: "when"
367 "where: start of previous non-comment line
368 "indent: follow
369 "keywords: "case"
370 "where: start of previous non-comment line
371 if m == 1
372 if ps =~? '^\s*end\s\+case\>'
Bram Moolenaar3ec574f2017-06-13 18:12:01 +0200373 return indent(pn) - 2 * shiftwidth()
Bram Moolenaar280f1262006-01-30 00:14:18 +0000374 elseif ps =~? '^\s*when\>'
Bram Moolenaar3ec574f2017-06-13 18:12:01 +0200375 return indent(pn) - shiftwidth()
Bram Moolenaar280f1262006-01-30 00:14:18 +0000376 elseif ps =~? '^\s*case\>'
377 return indent(pn)
378 endif
379 "indent: follow
380 "keyword: "component"
Bram Moolenaar9964e462007-05-05 17:54:07 +0000381 "where: start of previous non-comment line
Bram Moolenaar280f1262006-01-30 00:14:18 +0000382 elseif m == 2
Bram Moolenaar9964e462007-05-05 17:54:07 +0000383 if ps =~? '^\s*component\>'
Bram Moolenaar280f1262006-01-30 00:14:18 +0000384 return indent(pn)
385 endif
Bram Moolenaar51156d52006-01-26 22:17:47 +0000386 endif
387 endif
388 let pn = prevnonblank(pn - 1)
389 let ps = getline(pn)
390 endwhile
Bram Moolenaar3ec574f2017-06-13 18:12:01 +0200391 return ind - shiftwidth()
Bram Moolenaar51156d52006-01-26 22:17:47 +0000392 endif
393
Bram Moolenaarb8a7b562006-02-01 21:47:16 +0000394 " indent: -sw
395 " keyword: ")"
396 " where: start of current line
397 if curs =~ '^\s*)'
Bram Moolenaar3ec574f2017-06-13 18:12:01 +0200398 return ind - shiftwidth()
Bram Moolenaarb8a7b562006-02-01 21:47:16 +0000399 endif
400
Bram Moolenaar51156d52006-01-26 22:17:47 +0000401 " indent: 0
402 " keywords: "end" + "architecture", "configuration", "entity", "package"
403 " where: start of current line
404 if curs =~? '^\s*end\s\+\%(architecture\|configuration\|entity\|package\)\>'
405 return 0
406 endif
407
408 " indent: -sw
Bram Moolenaar9028b102010-07-11 16:58:51 +0200409 " keywords: "end" + identifier, ";"
Bram Moolenaar51156d52006-01-26 22:17:47 +0000410 " where: start of current line
Bram Moolenaar9964e462007-05-05 17:54:07 +0000411 "if curs =~? '^\s*end\s\+\w\+\>'
Bram Moolenaar9028b102010-07-11 16:58:51 +0200412 if curs =~? '^\s*end\%(\s\|;'.s:ES.'\)'
Bram Moolenaar3ec574f2017-06-13 18:12:01 +0200413 return ind - shiftwidth()
Bram Moolenaar51156d52006-01-26 22:17:47 +0000414 endif
415
416 " ****************************************************************************************
Bram Moolenaar280f1262006-01-30 00:14:18 +0000417 " indent: maintain indent of previous opening statement
Bram Moolenaar01164a62017-11-02 22:58:42 +0100418 " keywords: without "procedure", "generic", "map", "port" + ":" but not ":=" + "in", "out", "inout", "buffer", "linkage", variable & ":="
Bram Moolenaarb8a7b562006-02-01 21:47:16 +0000419 " where: start of current line
Bram Moolenaar01164a62017-11-02 22:58:42 +0100420 if curs =~? '^\s*\%(\<\%(procedure\|generic\|map\|port\)\>.*\)\@<!\w\+\s*\w*\s*:[^=]\@=\s*\%(\%(in\|out\|inout\|buffer\|linkage\)\>\|\w\+\s\+:=\)'
Bram Moolenaar51156d52006-01-26 22:17:47 +0000421 return ind2
422 endif
Bram Moolenaar01164a62017-11-02 22:58:42 +0100423
Bram Moolenaar82af8712016-06-04 20:20:29 +0200424 " ****************************************************************************************
425 " indent: maintain indent of previous opening statement, corner case which
426 " does not end in ;, but is part of a mapping
427 " keywords: without "procedure", "generic", "map", "port" + ":" but not ":=", never + ;$ and
428 " prevline without "procedure", "generic", "map", "port" + ":" but not ":=" + eventually ;$
429 " where: start of current line
430 if curs =~? '^\s*\%(\<\%(procedure\|generic\|map\|port\)\>.*\)\@<!\w\+\s*\w*\s*:[^=].*[^;].*$'
Bram Moolenaar01164a62017-11-02 22:58:42 +0100431 if prevs =~? '^\s*\%(\<\%(procedure\|generic\|map\|port\)\>.*\)\@<!\w\+\s*\w*\s*:[^=].*;.*$'
432 return ind2
433 endif
434 endif
Bram Moolenaar51156d52006-01-26 22:17:47 +0000435
436 " return leftover filtered indent
437 return ind
438endfunction