2725
|
1 " Vim indent file
|
28620
|
2 " Language: Treetop
|
|
3 " Maintainer: Doug Kearns <dougkearns@gmail.com>
|
|
4 " Previous Maintainer: Nikolai Weibull <now@bitwi.se>
|
|
5 " Last Change: 2022 April 25
|
2725
|
6
|
|
7 if exists("b:did_indent")
|
|
8 finish
|
|
9 endif
|
|
10 let b:did_indent = 1
|
|
11
|
|
12 setlocal indentexpr=GetTreetopIndent()
|
|
13 setlocal indentkeys=0{,0},!^F,o,O,=end
|
|
14 setlocal nosmartindent
|
|
15
|
28620
|
16 let b:undo_indent = "setl inde< indk< si<"
|
|
17
|
2725
|
18 if exists("*GetTreetopIndent")
|
|
19 finish
|
|
20 endif
|
|
21
|
|
22 function GetTreetopIndent()
|
|
23 let pnum = prevnonblank(v:lnum - 1)
|
|
24 if pnum == 0
|
|
25 return 0
|
|
26 endif
|
|
27
|
|
28 let ind = indent(pnum)
|
|
29 let line = getline(pnum)
|
|
30
|
|
31 if line =~ '^\s*\%(grammar\|module\|rule\)\>'
|
11160
|
32 let ind += shiftwidth()
|
2725
|
33 endif
|
|
34
|
|
35 let line = getline(v:lnum)
|
|
36 if line =~ '^\s*end\>'
|
11160
|
37 let ind -= shiftwidth()
|
2725
|
38 end
|
|
39
|
25773
|
40 return ind
|
2725
|
41 endfunction
|