Bram Moolenaar | 280f126 | 2006-01-30 00:14:18 +0000 | [diff] [blame] | 1 | " VHDL indent ('93 syntax) |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 2 | " Language: VHDL |
| 3 | " Maintainer: Gerald Lai <laigera+vim?gmail.com> |
Bram Moolenaar | 7fc904b | 2006-04-13 20:37:35 +0000 | [diff] [blame] | 4 | " Version: 1.36 |
| 5 | " Last Change: 2006 Apr 12 |
Bram Moolenaar | 280f126 | 2006-01-30 00:14:18 +0000 | [diff] [blame] | 6 | " URL: http://www.vim.org/scripts/script.php?script_id=1450 |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 7 | |
| 8 | " only load this indent file when no other was loaded |
| 9 | if exists("b:did_indent") |
| 10 | finish |
| 11 | endif |
| 12 | let b:did_indent = 1 |
| 13 | |
| 14 | " setup indent options for local VHDL buffer |
| 15 | setlocal indentexpr=GetVHDLindent() |
| 16 | setlocal indentkeys=!^F,o,O,e,0(,0) |
| 17 | setlocal indentkeys+==~if,=~then,=~elsif,=~else |
Bram Moolenaar | 7fc904b | 2006-04-13 20:37:35 +0000 | [diff] [blame] | 18 | setlocal indentkeys+==~begin,=~is,=~select |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 19 | |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 20 | " constants |
| 21 | " not a comment |
| 22 | let s:NC = '\%(--.*\)\@<!' |
| 23 | " end of string |
| 24 | let s:ES = '\s*\%(--.*\)\=$' |
| 25 | " no "end" keyword in front |
| 26 | let s:NE = '\%(\<end\s\+\)\@<!' |
| 27 | |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 28 | " only define indent function once |
| 29 | if exists("*GetVHDLindent") |
| 30 | finish |
| 31 | endif |
| 32 | |
| 33 | function GetVHDLindent() |
| 34 | " store current line & string |
| 35 | let curn = v:lnum |
| 36 | let curs = getline(curn) |
| 37 | |
| 38 | " find previous line that is not a comment |
| 39 | let prevn = prevnonblank(curn - 1) |
| 40 | let prevs = getline(prevn) |
| 41 | while prevn > 0 && prevs =~ '^\s*--' |
| 42 | let prevn = prevnonblank(prevn - 1) |
| 43 | let prevs = getline(prevn) |
| 44 | endwhile |
| 45 | |
| 46 | " default indent starts as previous non-comment line's indent |
| 47 | let ind = prevn > 0 ? indent(prevn) : 0 |
| 48 | " backup default |
| 49 | let ind2 = ind |
| 50 | |
Bram Moolenaar | 280f126 | 2006-01-30 00:14:18 +0000 | [diff] [blame] | 51 | " indent: special; kill string so it would not affect other filters |
| 52 | " keywords: "report" + string |
| 53 | " where: anywhere in current or previous line |
| 54 | let s0 = s:NC.'\<report\>\s*".*"' |
| 55 | if curs =~? s0 |
| 56 | let curs = "" |
| 57 | endif |
| 58 | if prevs =~? s0 |
| 59 | let prevs = "" |
| 60 | endif |
| 61 | |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 62 | " indent: previous line's comment position, otherwise follow next non-comment line if possible |
| 63 | " keyword: "--" |
| 64 | " where: start of current line |
| 65 | if curs =~ '^\s*--' |
| 66 | let pn = curn - 1 |
| 67 | let ps = getline(pn) |
| 68 | if ps =~ '--' |
| 69 | return stridx(ps, '--') |
| 70 | else |
| 71 | " find nextnonblank line that is not a comment |
| 72 | let nn = nextnonblank(curn + 1) |
| 73 | let ns = getline(nn) |
| 74 | while nn > 0 && ns =~ '^\s*--' |
| 75 | let nn = nextnonblank(nn + 1) |
| 76 | let ns = getline(nn) |
| 77 | endwhile |
| 78 | let n = indent(nn) |
| 79 | return n != -1 ? n : ind |
| 80 | endif |
| 81 | endif |
| 82 | |
| 83 | " **************************************************************************************** |
| 84 | " indent: align generic variables & port names |
| 85 | " keywords: "generic", "map", "port" + "(", provided current line is part of mapping |
| 86 | " where: anywhere in previous 2 lines |
| 87 | " find following previous non-comment line |
| 88 | let pn = prevnonblank(prevn - 1) |
| 89 | let ps = getline(pn) |
| 90 | while pn > 0 && ps =~ '^\s*--' |
| 91 | let pn = prevnonblank(pn - 1) |
| 92 | let ps = getline(pn) |
| 93 | endwhile |
Bram Moolenaar | b8a7b56 | 2006-02-01 21:47:16 +0000 | [diff] [blame] | 94 | if (curs =~ '^\s*)' || curs =~? '^\s*\%(\<\%(generic\|map\|port\)\>.*\)\@<!\S\+\s*\%(=>\s*\S\+\|:[^=]\@=\s*\%(\%(in\|out\|inout\|buffer\|linkage\)\>\|\w\+\s\+:=\)\)') && (prevs =~? s:NC.'\<\%(generic\|map\|port\)\s*(\%(\s*\w\)\=' || (ps =~? s:NC.'\<\%(generic\|map\|port\)'.s:ES && prevs =~ '^\s*(')) |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 95 | " align closing ")" with opening "(" |
| 96 | if curs =~ '^\s*)' |
| 97 | return stridx(prevs, '(') |
| 98 | endif |
| 99 | let m = matchend(prevs, '(\s*\ze\w') |
| 100 | if m != -1 |
| 101 | return m |
| 102 | else |
| 103 | return stridx(prevs, '(') + &sw |
| 104 | endif |
| 105 | endif |
| 106 | |
| 107 | " indent: align conditional/select statement |
Bram Moolenaar | 280f126 | 2006-01-30 00:14:18 +0000 | [diff] [blame] | 108 | " keywords: variable + "<=" without ";" ending |
| 109 | " where: start of previous line |
| 110 | if prevs =~? '^\s*\S\+\s*<=[^;]*'.s:ES |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 111 | return matchend(prevs, '<=\s*\ze.') |
| 112 | endif |
| 113 | |
| 114 | " indent: backtrace previous non-comment lines for next smaller or equal size indent |
| 115 | " keywords: "end" + "record", "units" |
| 116 | " where: start of previous line |
| 117 | " keyword: ")" |
| 118 | " where: start of previous line |
| 119 | " keyword: without "<=" + ";" ending |
| 120 | " where: anywhere in previous line |
| 121 | " keyword: "=>" + ")" ending, provided current line does not begin with ")" |
| 122 | " where: anywhere in previous line |
| 123 | " _note_: indent allowed to leave this filter |
| 124 | let m = 0 |
| 125 | if prevs =~? '^\s*end\s\+\%(record\|units\)\>' |
| 126 | let m = 3 |
| 127 | elseif prevs =~ '^\s*)' |
| 128 | let m = 1 |
| 129 | elseif prevs =~ s:NC.'\%(<=.*\)\@<!;'.s:ES || (curs !~ '^\s*)' && prevs =~ s:NC.'=>.*'.s:NC.')'.s:ES) |
| 130 | let m = 2 |
| 131 | endif |
| 132 | |
| 133 | if m > 0 |
| 134 | let pn = prevnonblank(prevn - 1) |
| 135 | let ps = getline(pn) |
| 136 | while pn > 0 |
| 137 | let t = indent(pn) |
| 138 | if ps !~ '^\s*--' && t < ind |
| 139 | " make sure one of these is true |
Bram Moolenaar | 280f126 | 2006-01-30 00:14:18 +0000 | [diff] [blame] | 140 | " keywords: variable + "<=" without ";" ending |
| 141 | " where: start of previous non-comment line |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 142 | " keywords: "generic", "map", "port" |
| 143 | " where: anywhere in previous non-comment line |
| 144 | " keyword: "(" |
| 145 | " where: start of previous non-comment line |
Bram Moolenaar | 280f126 | 2006-01-30 00:14:18 +0000 | [diff] [blame] | 146 | if m < 3 && ps !~? '^\s*\S\+\s*<=[^;]*'.s:ES |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 147 | if ps =~? s:NC.'\<\%(generic\|map\|port\)\>' || ps =~ '^\s*(' |
| 148 | let ind = t |
| 149 | endif |
| 150 | break |
| 151 | endif |
| 152 | let ind = t |
| 153 | if m > 1 |
| 154 | " find following previous non-comment line |
| 155 | let ppn = prevnonblank(pn - 1) |
| 156 | let pps = getline(ppn) |
| 157 | while ppn > 0 && pps =~ '^\s*--' |
| 158 | let ppn = prevnonblank(ppn - 1) |
| 159 | let pps = getline(ppn) |
| 160 | endwhile |
| 161 | " indent: follow |
| 162 | " keyword: "select" |
| 163 | " where: end of following previous non-comment line |
| 164 | " keyword: "type" |
| 165 | " where: start of following previous non-comment line |
| 166 | if m == 2 |
| 167 | let s1 = s:NC.'\<select'.s:ES |
| 168 | if ps !~? s1 && pps =~? s1 |
| 169 | let ind = indent(ppn) |
| 170 | endif |
| 171 | elseif m == 3 |
| 172 | let s1 = '^\s*type\>' |
| 173 | if ps !~? s1 && pps =~? s1 |
| 174 | let ind = indent(ppn) |
| 175 | endif |
| 176 | endif |
| 177 | endif |
| 178 | break |
| 179 | endif |
| 180 | let pn = prevnonblank(pn - 1) |
| 181 | let ps = getline(pn) |
| 182 | endwhile |
| 183 | endif |
| 184 | |
| 185 | " indent: follow indent of previous opening statement, otherwise -sw |
| 186 | " keyword: "begin" |
| 187 | " where: anywhere in current line |
| 188 | if curs =~? s:NC.'\<begin\>' |
| 189 | let ind = ind - &sw |
| 190 | " find previous opening statement of |
| 191 | " keywords: "architecture", "block", "entity", "function", "generate", "procedure", "process" |
| 192 | let s2 = s:NC.s:NE.'\<\%(architecture\|block\|entity\|function\|generate\|procedure\|process\)\>' |
| 193 | if curs !~? s2.'.*'.s:NC.'\<begin\>.*'.s:ES && prevs =~? s2 |
| 194 | let ind = ind + &sw |
| 195 | endif |
| 196 | return ind |
| 197 | endif |
| 198 | |
| 199 | " indent: +sw if previous line is previous opening statement |
| 200 | " keywords: "record", "units" |
| 201 | " where: anywhere in current line |
| 202 | if curs =~? s:NC.s:NE.'\<\%(record\|units\)\>' |
| 203 | " find previous opening statement of |
| 204 | " keyword: "type" |
| 205 | let s3 = s:NC.s:NE.'\<type\>' |
| 206 | if curs !~? s3.'.*'.s:NC.'\<\%(record\|units\)\>.*'.s:ES && prevs =~? s3 |
| 207 | let ind = ind + &sw |
| 208 | endif |
| 209 | return ind |
| 210 | endif |
| 211 | |
| 212 | " **************************************************************************************** |
| 213 | " indent: 0 |
| 214 | " keywords: "architecture", "configuration", "entity", "library", "package" |
| 215 | " where: start of current line |
| 216 | if curs =~? '^\s*\%(architecture\|configuration\|entity\|library\|package\)\>' |
| 217 | return 0 |
| 218 | endif |
| 219 | |
Bram Moolenaar | 280f126 | 2006-01-30 00:14:18 +0000 | [diff] [blame] | 220 | " indent: maintain indent of previous opening statement |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 221 | " keyword: "is" |
| 222 | " where: start of current line |
| 223 | " find previous opening statement of |
| 224 | " keywords: "architecture", "block", "configuration", "entity", "function", "package", "procedure", "process", "type" |
| 225 | if curs =~? '^\s*\<is\>' && prevs =~? s:NC.s:NE.'\<\%(architecture\|block\|configuration\|entity\|function\|package\|procedure\|process\|type\)\>' |
Bram Moolenaar | 280f126 | 2006-01-30 00:14:18 +0000 | [diff] [blame] | 226 | return ind2 |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 227 | endif |
| 228 | |
Bram Moolenaar | 280f126 | 2006-01-30 00:14:18 +0000 | [diff] [blame] | 229 | " indent: maintain indent of previous opening statement |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 230 | " keyword: "then" |
| 231 | " where: start of current line |
| 232 | " find previous opening statement of |
| 233 | " keywords: "elsif", "if" |
Bram Moolenaar | b8a7b56 | 2006-02-01 21:47:16 +0000 | [diff] [blame] | 234 | if curs =~? '^\s*\<then\>' && prevs =~? s:NC.'\%(\<elsif\>\|'.s:NE.'\<if\>\)' |
Bram Moolenaar | 280f126 | 2006-01-30 00:14:18 +0000 | [diff] [blame] | 235 | return ind2 |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 236 | endif |
| 237 | |
Bram Moolenaar | 280f126 | 2006-01-30 00:14:18 +0000 | [diff] [blame] | 238 | " indent: maintain indent of previous opening statement |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 239 | " keyword: "generate" |
| 240 | " where: start of current line |
| 241 | " find previous opening statement of |
| 242 | " keywords: "for", "if" |
Bram Moolenaar | b8a7b56 | 2006-02-01 21:47:16 +0000 | [diff] [blame] | 243 | if curs =~? '^\s*\<generate\>' && prevs =~? s:NC.s:NE.'\%(\%(\<wait\s\+\)\@<!\<for\>\|\<if\>\)' |
Bram Moolenaar | 280f126 | 2006-01-30 00:14:18 +0000 | [diff] [blame] | 244 | return ind2 |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 245 | endif |
| 246 | |
| 247 | " indent: +sw |
Bram Moolenaar | b8a7b56 | 2006-02-01 21:47:16 +0000 | [diff] [blame] | 248 | " keywords: "begin", "block", "loop", "process", "record", "units" |
| 249 | " removed: "case", "elsif", "if", "while" |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 250 | " where: anywhere in previous line |
Bram Moolenaar | b8a7b56 | 2006-02-01 21:47:16 +0000 | [diff] [blame] | 251 | if prevs =~? s:NC.'\%(\<begin\>\|'.s:NE.'\<\%(block\|loop\|process\|record\|units\)\>\)' |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 252 | return ind + &sw |
| 253 | endif |
| 254 | |
| 255 | " indent: +sw |
Bram Moolenaar | 280f126 | 2006-01-30 00:14:18 +0000 | [diff] [blame] | 256 | " keywords: "architecture", "component", "configuration", "entity", "for", "package" |
| 257 | " removed: "when", "with" |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 258 | " where: start of previous line |
Bram Moolenaar | 280f126 | 2006-01-30 00:14:18 +0000 | [diff] [blame] | 259 | if prevs =~? '^\s*\%(architecture\|component\|configuration\|entity\|for\|package\)\>' |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 260 | return ind + &sw |
| 261 | endif |
| 262 | |
| 263 | " indent: +sw |
| 264 | " keyword: "generate", "is", "select", "=>" |
| 265 | " where: end of previous line |
Bram Moolenaar | b8a7b56 | 2006-02-01 21:47:16 +0000 | [diff] [blame] | 266 | if prevs =~? s:NC.'\%(\%('.s:NE.'\<generate\|\<is\|\<select\)\|=>\)'.s:ES |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 267 | return ind + &sw |
| 268 | endif |
| 269 | |
| 270 | " indent: +sw |
Bram Moolenaar | b8a7b56 | 2006-02-01 21:47:16 +0000 | [diff] [blame] | 271 | " keyword: "else" |
| 272 | " where: start of previous line |
| 273 | " keyword: "then" |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 274 | " where: end of previous line |
| 275 | " _note_: indent allowed to leave this filter |
Bram Moolenaar | b8a7b56 | 2006-02-01 21:47:16 +0000 | [diff] [blame] | 276 | if prevs =~? '^\s*else\>' || prevs =~? s:NC.'\<then'.s:ES |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 277 | let ind = ind + &sw |
| 278 | endif |
| 279 | |
| 280 | " **************************************************************************************** |
Bram Moolenaar | b8a7b56 | 2006-02-01 21:47:16 +0000 | [diff] [blame] | 281 | " indent: -sw |
| 282 | " keywords: "when", provided previous line does not begin with "when" |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 283 | " where: start of current line |
| 284 | let s4 = '^\s*when\>' |
Bram Moolenaar | b8a7b56 | 2006-02-01 21:47:16 +0000 | [diff] [blame] | 285 | if curs =~? s4 |
| 286 | if prevs !~? s4 |
| 287 | return ind - &sw |
| 288 | else |
| 289 | return ind2 |
| 290 | endif |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 291 | endif |
| 292 | |
| 293 | " indent: -sw |
Bram Moolenaar | b8a7b56 | 2006-02-01 21:47:16 +0000 | [diff] [blame] | 294 | " keywords: "else", "elsif", provided previous line does not contain "then" |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 295 | " where: start of current line |
| 296 | if curs =~? '^\s*\%(else\|elsif\)\>' |
Bram Moolenaar | b8a7b56 | 2006-02-01 21:47:16 +0000 | [diff] [blame] | 297 | if prevs !~? s:NC.'\<then\>' |
| 298 | return ind - &sw |
| 299 | else |
| 300 | return ind2 |
| 301 | endif |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 302 | endif |
| 303 | |
| 304 | " indent: -sw |
Bram Moolenaar | b8a7b56 | 2006-02-01 21:47:16 +0000 | [diff] [blame] | 305 | " keywords: "end" + "if", provided previous line does not begin with "else", not contain "then" |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 306 | " where: start of current line |
Bram Moolenaar | b8a7b56 | 2006-02-01 21:47:16 +0000 | [diff] [blame] | 307 | if curs =~? '^\s*end\s\+if\>' |
| 308 | if prevs !~? '^\s*else\>' && prevs !~? s:NC.'\<then\>' |
| 309 | return ind - &sw |
| 310 | else |
| 311 | return ind2 |
| 312 | endif |
| 313 | endif |
| 314 | |
| 315 | " indent: -sw |
| 316 | " keywords: "end" + "function", "procedure", provided previous line does not contain "begin" |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 317 | " where: start of current line |
Bram Moolenaar | b8a7b56 | 2006-02-01 21:47:16 +0000 | [diff] [blame] | 318 | if curs =~? '^\s*end\s\+\%(function\|procedure\)\>' |
| 319 | if prevs !~? s:NC.'\<begin\>' |
| 320 | return ind - &sw |
| 321 | else |
| 322 | return ind2 |
| 323 | endif |
| 324 | endif |
| 325 | |
| 326 | " indent: -sw |
| 327 | " keywords: "end" + "block", "for", "generate", "loop", "process", "record", "units" |
| 328 | " where: start of current line |
| 329 | if curs =~? '^\s*end\s\+\%(block\|for\|generate\|loop\|process\|record\|units\)\>' |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 330 | return ind - &sw |
| 331 | endif |
| 332 | |
Bram Moolenaar | 280f126 | 2006-01-30 00:14:18 +0000 | [diff] [blame] | 333 | " indent: backtrace previous non-comment lines |
| 334 | " keyword: "end" + "case", "component" |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 335 | " where: start of current line |
Bram Moolenaar | 280f126 | 2006-01-30 00:14:18 +0000 | [diff] [blame] | 336 | let m = 0 |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 337 | if curs =~? '^\s*end\s\+case\>' |
Bram Moolenaar | 280f126 | 2006-01-30 00:14:18 +0000 | [diff] [blame] | 338 | let m = 1 |
| 339 | elseif curs =~? '^\s*end\s\+component\>' |
| 340 | let m = 2 |
| 341 | endif |
| 342 | |
| 343 | if m > 0 |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 344 | " find following previous non-comment line |
| 345 | let pn = prevn |
| 346 | let ps = getline(pn) |
| 347 | while pn > 0 |
| 348 | if ps !~ '^\s*--' |
Bram Moolenaar | 280f126 | 2006-01-30 00:14:18 +0000 | [diff] [blame] | 349 | "indent: -2sw |
| 350 | "keywords: "end" + "case" |
| 351 | "where: start of previous non-comment line |
| 352 | "indent: -sw |
| 353 | "keywords: "when" |
| 354 | "where: start of previous non-comment line |
| 355 | "indent: follow |
| 356 | "keywords: "case" |
| 357 | "where: start of previous non-comment line |
| 358 | if m == 1 |
| 359 | if ps =~? '^\s*end\s\+case\>' |
| 360 | return indent(pn) - 2 * &sw |
| 361 | elseif ps =~? '^\s*when\>' |
| 362 | return indent(pn) - &sw |
| 363 | elseif ps =~? '^\s*case\>' |
| 364 | return indent(pn) |
| 365 | endif |
| 366 | "indent: follow |
| 367 | "keyword: "component" |
| 368 | "where: anywhere in previous non-comment line |
| 369 | elseif m == 2 |
| 370 | if ps =~? s:NC.s:NE.'\<component\>' |
| 371 | return indent(pn) |
| 372 | endif |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 373 | endif |
| 374 | endif |
| 375 | let pn = prevnonblank(pn - 1) |
| 376 | let ps = getline(pn) |
| 377 | endwhile |
Bram Moolenaar | 280f126 | 2006-01-30 00:14:18 +0000 | [diff] [blame] | 378 | return ind - &sw |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 379 | endif |
| 380 | |
Bram Moolenaar | b8a7b56 | 2006-02-01 21:47:16 +0000 | [diff] [blame] | 381 | " indent: -sw |
| 382 | " keyword: ")" |
| 383 | " where: start of current line |
| 384 | if curs =~ '^\s*)' |
| 385 | return ind - &sw |
| 386 | endif |
| 387 | |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 388 | " indent: 0 |
| 389 | " keywords: "end" + "architecture", "configuration", "entity", "package" |
| 390 | " where: start of current line |
| 391 | if curs =~? '^\s*end\s\+\%(architecture\|configuration\|entity\|package\)\>' |
| 392 | return 0 |
| 393 | endif |
| 394 | |
| 395 | " indent: -sw |
| 396 | " keywords: "end" + identifier |
| 397 | " where: start of current line |
| 398 | if curs =~? '^\s*end\s\+\w\+\>' |
| 399 | return ind - &sw |
| 400 | endif |
| 401 | |
| 402 | " **************************************************************************************** |
Bram Moolenaar | 280f126 | 2006-01-30 00:14:18 +0000 | [diff] [blame] | 403 | " indent: maintain indent of previous opening statement |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 404 | " keywords: without "generic", "map", "port" + ":" but not ":=" + "in", "out", "inout", "buffer", "linkage", variable & ":=" |
Bram Moolenaar | b8a7b56 | 2006-02-01 21:47:16 +0000 | [diff] [blame] | 405 | " where: start of current line |
| 406 | if curs =~? '^\s*\%(\<\%(generic\|map\|port\)\>.*\)\@<!\S\+\s*:[^=]\@=\s*\%(\%(in\|out\|inout\|buffer\|linkage\)\>\|\w\+\s\+:=\)' |
Bram Moolenaar | 51156d5 | 2006-01-26 22:17:47 +0000 | [diff] [blame] | 407 | return ind2 |
| 408 | endif |
| 409 | |
| 410 | " return leftover filtered indent |
| 411 | return ind |
| 412 | endfunction |