3 " Maintainer: Nikolai Weibull <now@bitwi.se>
4 " Latest Revision: 2006-12-20
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)
67 elseif line =~ '^\s*}'
68 return indent(v:lnum) - &sw
71 let pnum = s:prevnonblanknoncomment(v:lnum - 1)
76 let ind = indent(pnum) + s:count_braces(pnum, 1) * &sw
78 let pline = getline(pnum)
80 let ind -= (s:count_braces(pnum, 0) - (pline =~ '^\s*}' ? 1 : 0)) * &sw