robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
521e91e1c4
master
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 7if exists ( "b:did_indent" ) 8finish 9endif 10let b: did_indent = 1 11 12setlocal indentexpr = GetXinetdIndent () 13setlocal indentkeys = 0{,0},!^F,o,O 14setlocal nosmartindent 15 16let b: undo_indent = "setl inde< indk< si<" 17 18if exists ( "*GetXinetdIndent" ) 19finish 20endif 21let s: keepcpo = & cpo 22set cpo & vim 23 24function s: count_braces ( lnum , count_open ) 25let n_open = 0 26let n_close = 0 27let line = getline ( a: lnum ) 28let pattern = '[{}]' 29let i = match ( line , pattern ) 30while i != -1 31if synIDattr ( synID ( a: lnum , i + 1 , 0 ), 'name' ) !~ 'ld\%(Comment\|String\)' 32if line [ i ] == '{' 33let n_open += 1 34elseif line [ i ] == '}' 35if n_open > 0 36let n_open -= 1 37else 38let n_close += 1 39endif 40endif 41endif 42let i = match ( line , pattern , i + 1 ) 43endwhile 44return a: count_open ? n_open : n_close 45endfunction 46 47function GetXinetdIndent () 48let pnum = prevnonblank ( v: lnum - 1 ) 49if pnum == 0 50return 0 51endif 52 53return indent ( pnum ) + s: count_braces ( pnum , 1 ) * shiftwidth () 54 \- s: count_braces ( v: lnum , 0 ) * shiftwidth () 55endfunction 56 57let & cpo = s: keepcpo 58unlet s: keepcpo