1" Vim indent file 2" Language: xinetd.conf(5) configuration file 3" Previous Maintainer: Nikolai Weibull <[email protected]> 4" Latest Revision: 2006-12-20 5 6if exists("b:did_indent") 7 finish 8endif 9let b:did_indent = 1 10 11setlocal indentexpr=GetXinetdIndent() 12setlocal indentkeys=0{,0},!^F,o,O 13setlocal nosmartindent 14 15if exists("*GetXinetdIndent") 16 finish 17endif 18let s:keepcpo= &cpo 19set cpo&vim 20 21function s:count_braces(lnum, count_open) 22 let n_open = 0 23 let n_close = 0 24 let line = getline(a:lnum) 25 let pattern = '[{}]' 26 let i = match(line, pattern) 27 while i != -1 28 if synIDattr(synID(a:lnum, i + 1, 0), 'name') !~ 'ld\%(Comment\|String\)' 29 if line[i] == '{' 30 let n_open += 1 31 elseif line[i] == '}' 32 if n_open > 0 33 let n_open -= 1 34 else 35 let n_close += 1 36 endif 37 endif 38 endif 39 let i = match(line, pattern, i + 1) 40 endwhile 41 return a:count_open ? n_open : n_close 42endfunction 43 44function GetXinetdIndent() 45 let pnum = prevnonblank(v:lnum - 1) 46 if pnum == 0 47 return 0 48 endif 49 50 return indent(pnum) + s:count_braces(pnum, 1) * shiftwidth() 51 \ - s:count_braces(v:lnum, 0) * shiftwidth() 52endfunction 53 54let &cpo = s:keepcpo 55unlet s:keepcpo 56