annotate runtime/indent/sdl.vim @ 232:41e7594cac8b

updated for version 7.0065
author vimboss
date Mon, 28 Mar 2005 20:49:18 +0000
parents 3fc0f57ecb91
children 91e53bcb7946
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: SDL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 " Maintainer: Michael Piefel <piefel@informatik.hu-berlin.de>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 " Last Change: 2001 Sep 17
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 " Shamelessly stolen from the Vim-Script indent file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 " Only load this indent file when no other was loaded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 setlocal indentexpr=GetSDLIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 setlocal indentkeys+==~end,=~state,*<Return>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 " Only define the function once.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 if exists("*GetSDLIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 " finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 set cpo-=C
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 function! GetSDLIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 " Find a non-blank line above the current line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 let lnum = prevnonblank(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 " At the start of the file use zero indent.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 if lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 let ind = indent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 let virtuality = '^\s*\(\(virtual\|redefined\|finalized\)\s\+\)\=\s*'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 " Add a single space to comments which use asterisks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 if getline(lnum) =~ '^\s*\*'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 let ind = ind - 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 if getline(v:lnum) =~ '^\s*\*'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 let ind = ind + 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 " Add a 'shiftwidth' after states, different blocks, decision (and alternatives), inputs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 if (getline(lnum) =~? '^\s*\(start\|state\|system\|package\|connection\|channel\|alternative\|macro\|operator\|newtype\|select\|substructure\|decision\|generator\|refinement\|service\|method\|exceptionhandler\|asntype\|syntype\|value\|(.*):\|\(priority\s\+\)\=input\|provided\)'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 \ || getline(lnum) =~? virtuality . '\(process\|procedure\|block\|object\)')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 \ && getline(lnum) !~? 'end[[:alpha:]]\+;$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 let ind = ind + &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 " Subtract a 'shiftwidth' after states
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 if getline(lnum) =~? '^\s*\(stop\|return\>\|nextstate\)'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 let ind = ind - &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 " Subtract a 'shiftwidth' on on end (uncompleted line)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 if getline(v:lnum) =~? '^\s*end\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 let ind = ind - &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 " Put each alternatives where the corresponding decision was
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 if getline(v:lnum) =~? '^\s*\((.*)\|else\):'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 normal k
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 let ind = indent(searchpair('^\s*decision', '', '^\s*enddecision', 'bW',
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "sdlString"'))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 " Put each state where the preceding state was
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 if getline(v:lnum) =~? '^\s*state\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 let ind = indent(search('^\s*start', 'bW'))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 " Systems and packages are always in column 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 if getline(v:lnum) =~? '^\s*\(\(end\)\=system\|\(end\)\=package\)'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 " Put each end* where the corresponding begin was
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 if getline(v:lnum) =~? '^\s*end[[:alpha:]]'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 normal k
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 let partner=matchstr(getline(v:lnum), '\(' . virtuality . 'end\)\@<=[[:alpha:]]\+')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 let ind = indent(searchpair(virtuality . partner, '', '^\s*end' . partner, 'bW',
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "sdlString"'))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 " vim:sw=2