Mercurial > vim
comparison runtime/indent/xinetd.vim @ 375:f14cbd913415 v7.0097
updated for version 7.0097
author | vimboss |
---|---|
date | Wed, 29 Jun 2005 22:40:58 +0000 |
parents | |
children | 1f3b1021f002 |
comparison
equal
deleted
inserted
replaced
374:575dacb554d8 | 375:f14cbd913415 |
---|---|
1 " Vim indent file | |
2 " Language: xinetd.conf(5) configuration file | |
3 " Maintainer: Nikolai Weibull <nikolai+work.vim@bitwi.se> | |
4 " Latest Revision: 2005-06-28 | |
5 | |
6 if exists("b:did_indent") | |
7 finish | |
8 endif | |
9 let b:did_indent = 1 | |
10 | |
11 setlocal indentexpr=GetXinetdIndent() | |
12 setlocal indentkeys=0{,0},!^F,o,O | |
13 | |
14 if exists("*GetXinetdIndent") | |
15 finish | |
16 endif | |
17 | |
18 function s:count_braces(lnum, count_open) | |
19 let n_open = 0 | |
20 let n_close = 0 | |
21 let line = getline(a:lnum) | |
22 let pattern = '[{}]' | |
23 let i = match(line, pattern) | |
24 while i != -1 | |
25 if synIDattr(synID(a:lnum, i + 1, 0), 'name') !~ 'ld\%(Comment\|String\)' | |
26 if line[i] == '{' | |
27 let n_open += 1 | |
28 elseif line[i] == '}' | |
29 if n_open > 0 | |
30 let n_open -= 1 | |
31 else | |
32 let n_close += 1 | |
33 endif | |
34 endif | |
35 endif | |
36 let i = match(line, pattern, i + 1) | |
37 endwhile | |
38 return a:count_open ? n_open : n_close | |
39 endfunction | |
40 | |
41 function GetXinetdIndent() | |
42 let pnum = prevnonblank(v:lnum - 1) | |
43 if pnum == 0 | |
44 return 0 | |
45 endif | |
46 | |
47 return indent(pnum) + s:count_braces(pnum, 1) * &sw | |
48 \ - s:count_braces(v:lnum, 0) * &sw | |
49 endfunction |