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