comparison runtime/indent/css.vim @ 48:67300faee616 v7-3-618

v7-3-618
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 01 Aug 2012 18:08:28 +0900
parents 76efa0be13f1
children
comparison
equal deleted inserted replaced
47:6c0584ec21b1 48:67300faee616
1 " Vim indent file 1 " Vim indent file
2 " Language: CSS 2 " Language: CSS
3 " Maintainer: Nikolai Weibull <now@bitwi.se> 3 " Maintainer: Nikolai Weibull <now@bitwi.se>
4 " Latest Revision: 2006-12-20 4 " Latest Revision: 2012-05-30
5 5
6 if exists("b:did_indent") 6 if exists("b:did_indent")
7 finish 7 finish
8 endif 8 endif
9 let b:did_indent = 1 9 let b:did_indent = 1
10 10
11 setlocal indentexpr=GetCSSIndent() 11 setlocal indentexpr=GetCSSIndent()
12 setlocal indentkeys=0{,0},!^F,o,O 12 setlocal indentkeys=0{,0},!^F,o,O
13 setlocal nosmartindent 13 setlocal nosmartindent
14 14
15 let b:undo_indent = "setl smartindent< indentkeys< indentexpr<"
16
15 if exists("*GetCSSIndent") 17 if exists("*GetCSSIndent")
16 finish 18 finish
17 endif 19 endif
20 let s:keepcpo= &cpo
21 set cpo&vim
18 22
19 function s:prevnonblanknoncomment(lnum) 23 function s:prevnonblanknoncomment(lnum)
20 let lnum = a:lnum 24 let lnum = a:lnum
21 while lnum > 1 25 while lnum > 1
22 let lnum = prevnonblank(lnum) 26 let lnum = prevnonblank(lnum)
62 66
63 function GetCSSIndent() 67 function GetCSSIndent()
64 let line = getline(v:lnum) 68 let line = getline(v:lnum)
65 if line =~ '^\s*\*' 69 if line =~ '^\s*\*'
66 return cindent(v:lnum) 70 return cindent(v:lnum)
67 elseif line =~ '^\s*}'
68 return indent(v:lnum) - &sw
69 endif 71 endif
70 72
71 let pnum = s:prevnonblanknoncomment(v:lnum - 1) 73 let pnum = s:prevnonblanknoncomment(v:lnum - 1)
72 if pnum == 0 74 if pnum == 0
73 return 0 75 return 0
74 endif 76 endif
75 77
76 let ind = indent(pnum) + s:count_braces(pnum, 1) * &sw 78 return indent(pnum) + s:count_braces(pnum, 1) * &sw
79 \ - s:count_braces(v:lnum, 0) * &sw
80 endfunction
77 81
78 let pline = getline(pnum) 82 let &cpo = s:keepcpo
79 if pline =~ '}\s*$' 83 unlet s:keepcpo
80 let ind -= (s:count_braces(pnum, 0) - (pline =~ '^\s*}' ? 1 : 0)) * &sw
81 endif
82
83 return ind
84 endfunction