xref: /vim-8.2.3635/runtime/indent/css.vim (revision 42eeac35)
1" Vim indent file
2" Language:         CSS
3" Maintainer:       Nikolai Weibull <[email protected]>
4" Latest Revision:  2005-06-29
5
6if exists("b:did_indent")
7  finish
8endif
9let b:did_indent = 1
10
11setlocal indentexpr=GetCSSIndent()
12setlocal indentkeys=0{,0},!^F,o,O
13
14if exists("*GetCSSIndent")
15  finish
16endif
17
18function s:LookupLine(lnum)
19  let lnum = prevnonblank(a:lnum - 1)
20  while lnum > 0
21    let line = getline(lnum)
22
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
35endfunction
36
37function GetCSSIndent()
38  let lnum = prevnonblank(v:lnum - 1)
39  if lnum == 0
40    return 0
41  endif
42
43  let ind = indent(lnum)
44
45  if substitute(getline(lnum), '/\*.*', '', 'e') =~ '{\(.*}\)\@!'
46    let ind = ind + &sw
47  endif
48
49  if getline(v:lnum) =~ '^\s*}'
50    let ind = ind - &sw
51  endif
52
53  return ind
54endfunction
55