3 " Maintainer: Todd Zullinger <tmz@pobox.com>
4 " Last Change: 2009 Aug 19
7 if exists("b:did_indent")
12 setlocal autoindent smartindent
13 setlocal indentexpr=GetPuppetIndent()
14 setlocal indentkeys+=0],0)
16 if exists("*GetPuppetIndent")
20 " Check if a line is part of an include 'block', e.g.:
24 function! s:PartOfInclude(lnum)
28 let line = getline(lnum)
32 if line =~ '^\s*include\s\+[^,]\+,$'
39 function! s:OpenBrace(lnum)
40 call cursor(a:lnum, 1)
41 return searchpair('{\|\[\|(', '', '}\|\]\|)', 'nbW')
44 function! GetPuppetIndent()
45 let pnum = prevnonblank(v:lnum - 1)
50 let line = getline(v:lnum)
51 let pline = getline(pnum)
52 let ind = indent(pnum)
58 if pline =~ '\({\|\[\|(\|:\)$'
60 elseif pline =~ ';$' && pline !~ '[^:]\+:.*[=+]>.*'
62 elseif pline =~ '^\s*include\s\+.*,$'
66 if pline !~ ',$' && s:PartOfInclude(pnum)
70 " Match } }, }; ] ]: )
71 if line =~ '^\s*\(}\(,\|;\)\?$\|]:\?$\|)\)'
72 let ind = indent(s:OpenBrace(v:lnum))