blob: 4ea8f6a2d7829f7ae901fb33bc4b647262140142 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim indent file
2" Language: YACC input file
3" Maintainer: Nikolai Weibull <source@pcppopper.org>
4" URL: http://www.pcppopper.org/vim/indent/pcp/yacc/
5" Latest Revision: 2004-04-25
6" arch-tag: 629aa719-8fe4-4787-adb7-ae94ca801610
7
8" Only load this indent file when no other was loaded.
9if exists("b:did_indent")
10 finish
11endif
12
13let b:did_indent = 1
14
15setlocal indentexpr=GetYaccIndent()
16setlocal indentkeys=!^F,o,O
17
18" Only define the function once.
19if exists("*GetYaccIndent")
20 finish
21endif
22
23function GetYaccIndent()
24 if v:lnum == 1
25 return 0
26 endif
27
28 let ind = indent(v:lnum - 1)
29 let line = getline(v:lnum - 1)
30
31 if line == ''
32 let ind = 0
33 elseif line =~ '^\w\+\s*:'
34 let ind = ind + matchend(line, '^\w\+\s*')
35 elseif line =~ '^\s*;'
36 let ind = 0
37 else
38 let ind = indent(v:lnum)
39 endif
40
41 return ind
42endfunction
43
44" vim: set sts=2 sw=2: