Patch 7.0.084
[MacVim.git] / runtime / indent / yacc.vim
blob597a2cc83a3032073ec1c8a7869da3f958e54ebb
1 " Vim indent file
2 " Language:         YACC input file
3 " Maintainer:       Nikolai Weibull <now@bitwi.se>
4 " Latest Revision:  2006-04-19
6 " Only load this indent file when no other was loaded.
7 if exists("b:did_indent")
8   finish
9 endif
11 let b:did_indent = 1
13 setlocal indentexpr=GetYaccIndent()
14 setlocal indentkeys=!^F,o,O
16 " Only define the function once.
17 if exists("*GetYaccIndent")
18   finish
19 endif
21 function GetYaccIndent()
22   if v:lnum == 1
23     return 0
24   endif
26   let ind = indent(v:lnum - 1)
27   let line = getline(v:lnum - 1)
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
39   return ind
40 endfunction