blob: 42ec1c8ad98685820e7ca162e1aea3301a888120 [file] [log] [blame]
Bram Moolenaar662db672011-03-22 14:05:35 +01001" Vim indent file
Bram Moolenaar214641f2017-03-05 17:04:09 +01002" Language: Treetop
3" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
4" Latest Revision: 2011-03-14
Bram Moolenaar662db672011-03-22 14:05:35 +01005
6if exists("b:did_indent")
7 finish
8endif
9let b:did_indent = 1
10
11setlocal indentexpr=GetTreetopIndent()
12setlocal indentkeys=0{,0},!^F,o,O,=end
13setlocal nosmartindent
14
15if exists("*GetTreetopIndent")
16 finish
17endif
18
19function GetTreetopIndent()
20 let pnum = prevnonblank(v:lnum - 1)
21 if pnum == 0
22 return 0
23 endif
24
25 let ind = indent(pnum)
26 let line = getline(pnum)
27
28 if line =~ '^\s*\%(grammar\|module\|rule\)\>'
Bram Moolenaar036986f2017-03-16 17:41:02 +010029 let ind += shiftwidth()
Bram Moolenaar662db672011-03-22 14:05:35 +010030 endif
31
32 let line = getline(v:lnum)
33 if line =~ '^\s*end\>'
Bram Moolenaar036986f2017-03-16 17:41:02 +010034 let ind -= shiftwidth()
Bram Moolenaar662db672011-03-22 14:05:35 +010035 end
36
Bram Moolenaar6c391a72021-09-09 21:55:11 +020037 return ind
Bram Moolenaar662db672011-03-22 14:05:35 +010038endfunction