3 " Maintainer: Nikolai Weibull <now@bitwi.se>
4 " Latest Revision: 2006-04-19
6 if exists("b:did_indent")
11 setlocal indentexpr=GetCSSIndent()
12 setlocal indentkeys=0{,0},!^F,o,O
14 if exists("*GetCSSIndent")
18 function s:prevnonblanknoncomment(lnum)
21 let lnum = prevnonblank(lnum)
22 let line = getline(lnum)
24 while lnum > 1 && line !~ '/\*'
39 function s:count_braces(lnum, count_open)
42 let line = getline(a:lnum)
44 let i = match(line, pattern)
46 if synIDattr(synID(a:lnum, i + 1, 0), 'name') !~ 'css\%(Comment\|StringQ\{1,2}\)'
57 let i = match(line, pattern, i + 1)
59 return a:count_open ? n_open : n_close
62 function GetCSSIndent()
63 let line = getline(v:lnum)
65 return cindent(v:lnum)
66 elseif line =~ '^\s*}'
67 return indent(v:lnum) - &sw
70 let pnum = s:prevnonblanknoncomment(v:lnum - 1)
75 let ind = indent(pnum) + s:count_braces(pnum, 1) * &sw
77 let pline = getline(pnum)
79 let ind -= (s:count_braces(pnum, 0) - (pline =~ '^\s*}' ? 1 : 0)) * &sw