Mercurial > hg > RemoteEditor > vim7
comparison runtime/indent/xinetd.vim @ 0:76efa0be13f1
Initial revision
author | atsuki |
---|---|
date | Sat, 10 Nov 2007 15:07:22 +0900 |
parents | |
children | 67300faee616 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:76efa0be13f1 |
---|---|
1 " Vim indent file | |
2 " Language: xinetd.conf(5) configuration file | |
3 " Maintainer: Nikolai Weibull <now@bitwi.se> | |
4 " Latest Revision: 2006-12-20 | |
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 setlocal nosmartindent | |
14 | |
15 if exists("*GetXinetdIndent") | |
16 finish | |
17 endif | |
18 | |
19 function s:count_braces(lnum, count_open) | |
20 let n_open = 0 | |
21 let n_close = 0 | |
22 let line = getline(a:lnum) | |
23 let pattern = '[{}]' | |
24 let i = match(line, pattern) | |
25 while i != -1 | |
26 if synIDattr(synID(a:lnum, i + 1, 0), 'name') !~ 'ld\%(Comment\|String\)' | |
27 if line[i] == '{' | |
28 let n_open += 1 | |
29 elseif line[i] == '}' | |
30 if n_open > 0 | |
31 let n_open -= 1 | |
32 else | |
33 let n_close += 1 | |
34 endif | |
35 endif | |
36 endif | |
37 let i = match(line, pattern, i + 1) | |
38 endwhile | |
39 return a:count_open ? n_open : n_close | |
40 endfunction | |
41 | |
42 function GetXinetdIndent() | |
43 let pnum = prevnonblank(v:lnum - 1) | |
44 if pnum == 0 | |
45 return 0 | |
46 endif | |
47 | |
48 return indent(pnum) + s:count_braces(pnum, 1) * &sw | |
49 \ - s:count_braces(v:lnum, 0) * &sw | |
50 endfunction |