7
|
1 " Vim indent file
|
375
|
2 " Language: CSS
|
|
3 " Maintainer: Nikolai Weibull <nikolai+work.vim@bitwi.se>
|
|
4 " Latest Revision: 2005-06-29
|
7
|
5
|
|
6 if exists("b:did_indent")
|
|
7 finish
|
|
8 endif
|
|
9 let b:did_indent = 1
|
|
10
|
|
11 setlocal indentexpr=GetCSSIndent()
|
375
|
12 setlocal indentkeys=0{,0},!^F,o,O
|
7
|
13
|
|
14 if exists("*GetCSSIndent")
|
|
15 finish
|
|
16 endif
|
|
17
|
375
|
18 function s:LookupLine(lnum)
|
7
|
19 let lnum = prevnonblank(a:lnum - 1)
|
375
|
20 while lnum > 0
|
|
21 let line = getline(lnum)
|
7
|
22
|
375
|
23 if line =~ '\*/'
|
|
24 while lnum > 0 && line !~ '/\*'
|
|
25 let lnum -= 1
|
|
26 let line = getline(lnum)
|
|
27 endwhile
|
|
28 endif
|
|
29
|
|
30 if line !~ '^\s*/\*'
|
|
31 return lnum
|
|
32 end
|
|
33 endwhile
|
|
34 return lnum
|
|
35 endfunction
|
|
36
|
|
37 function GetCSSIndent()
|
|
38 let lnum = prevnonblank(v:lnum - 1)
|
7
|
39 if lnum == 0
|
|
40 return 0
|
|
41 endif
|
|
42
|
|
43 let ind = indent(lnum)
|
|
44
|
375
|
45 if substitute(getline(lnum), '/\*.*', '', 'e') =~ '{\(.*}\)\@!'
|
7
|
46 let ind = ind + &sw
|
|
47 endif
|
|
48
|
375
|
49 if getline(v:lnum) =~ '^\s*}'
|
|
50 let ind = ind - &sw
|
7
|
51 endif
|
|
52
|
|
53 return ind
|
|
54 endfunction
|