3 " Maintainer: Nikolai Weibull <now@bitwi.se>
4 " Latest Revision: 2010-12-22
6 if exists("b:did_indent")
11 setlocal indentexpr=GetCSSIndent()
12 setlocal indentkeys=0{,0},!^F,o,O
13 setlocal nosmartindent
15 if exists("*GetCSSIndent")
19 function s:prevnonblanknoncomment(lnum)
22 let lnum = prevnonblank(lnum)
23 let line = getline(lnum)
25 while lnum > 1 && line !~ '/\*'
40 function s:count_braces(lnum, count_open)
43 let line = getline(a:lnum)
45 let i = match(line, pattern)
47 if synIDattr(synID(a:lnum, i + 1, 0), 'name') !~ 'css\%(Comment\|StringQ\{1,2}\)'
58 let i = match(line, pattern, i + 1)
60 return a:count_open ? n_open : n_close
63 function GetCSSIndent()
64 let line = getline(v:lnum)
66 return cindent(v:lnum)
69 let pnum = s:prevnonblanknoncomment(v:lnum - 1)
74 return indent(pnum) + s:count_braces(pnum, 1) * &sw
75 \ - s:count_braces(v:lnum, 0) * &sw