7
|
1 " Vim indent file
|
375
|
2 " Language: YACC input file
|
|
3 " Maintainer: Nikolai Weibull <nikolai+work.vim@bitwi.se>
|
|
4 " Latest Revision: 2005-06-29
|
7
|
5
|
|
6 " Only load this indent file when no other was loaded.
|
|
7 if exists("b:did_indent")
|
|
8 finish
|
|
9 endif
|
|
10
|
|
11 let b:did_indent = 1
|
|
12
|
|
13 setlocal indentexpr=GetYaccIndent()
|
|
14 setlocal indentkeys=!^F,o,O
|
|
15
|
|
16 " Only define the function once.
|
|
17 if exists("*GetYaccIndent")
|
|
18 finish
|
|
19 endif
|
|
20
|
|
21 function GetYaccIndent()
|
|
22 if v:lnum == 1
|
|
23 return 0
|
|
24 endif
|
|
25
|
|
26 let ind = indent(v:lnum - 1)
|
|
27 let line = getline(v:lnum - 1)
|
|
28
|
|
29 if line == ''
|
|
30 let ind = 0
|
|
31 elseif line =~ '^\w\+\s*:'
|
|
32 let ind = ind + matchend(line, '^\w\+\s*')
|
|
33 elseif line =~ '^\s*;'
|
|
34 let ind = 0
|
|
35 else
|
|
36 let ind = indent(v:lnum)
|
|
37 endif
|
|
38
|
|
39 return ind
|
|
40 endfunction
|