4223
|
1 " Only load this one if no other indent file was loaded.
|
|
2 if exists("b:did_indent")
|
|
3 finish
|
|
4 endif
|
|
5
|
|
6 let b:did_indent = 1
|
|
7 setlocal indentexpr=GetPlokiIndent()
|
|
8 setlocal indentkeys=!^F,o,O,0=ELSE,0=END\ IF,0=FI,0=KTHX
|
|
9
|
|
10 " Only define the function once.
|
|
11 if exists("*GetPlokiIndent")
|
|
12 finish
|
|
13 endif
|
|
14
|
|
15 function GetPlokiIndent()
|
|
16 if v:lnum == 1
|
|
17 return 0
|
|
18 endif
|
|
19
|
|
20 let plnum = v:lnum - 1
|
|
21 let prevline = getline(plnum)
|
|
22 while plnum > 0 && prevline =~ '^\s*$'
|
|
23 let plnum = plnum - 1
|
|
24 let prevline = getline(plnum)
|
|
25 endwhile
|
|
26
|
|
27 let ind = indent(plnum)
|
|
28 let thisline = getline(v:lnum)
|
|
29
|
|
30 if prevline =~ '^FOR\%(\s*\S\+\)\@>\%(\s*KTHX\)\@!'
|
|
31 let ind = ind + &sw
|
|
32 endif
|
|
33 if prevline =~ '^\s*\%(FOR\s*\S\+\|\d*\)\s*\%(IF\|ELSE\)'
|
|
34 let ind = ind + &sw
|
|
35 endif
|
|
36 if thisline =~ '^\s*\%(FOR\s*\S\+\|\d*\)\s*\%(ELSE\|END IF\|FI\)'
|
|
37 let ind = ind - &sw
|
|
38 elseif ind == &sw && thisline =~ '^\s*\%(\d\+\s*\)\=KTHX'
|
|
39 let ind = ind - &sw
|
|
40 endif
|
|
41
|
|
42 return ind
|
|
43 endfunction
|