Mercurial > vim
comparison runtime/indent/css.vim @ 1189:7cdd85615e4e
updated for version 7.1b
author | vimboss |
---|---|
date | Thu, 10 May 2007 16:50:23 +0000 |
parents | 8cd729851562 |
children | b6471224d2af |
comparison
equal
deleted
inserted
replaced
1188:2a276274c592 | 1189:7cdd85615e4e |
---|---|
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-04-19 | 4 " Latest Revision: 2006-12-20 |
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 | 14 |
14 if exists("*GetCSSIndent") | 15 if exists("*GetCSSIndent") |
15 finish | 16 finish |
16 endif | 17 endif |
17 | 18 |
20 while lnum > 1 | 21 while lnum > 1 |
21 let lnum = prevnonblank(lnum) | 22 let lnum = prevnonblank(lnum) |
22 let line = getline(lnum) | 23 let line = getline(lnum) |
23 if line =~ '\*/' | 24 if line =~ '\*/' |
24 while lnum > 1 && line !~ '/\*' | 25 while lnum > 1 && line !~ '/\*' |
25 let lnum -= 1 | 26 let lnum -= 1 |
26 endwhile | 27 endwhile |
27 if line =~ '^\s*/\*' | 28 if line =~ '^\s*/\*' |
28 let lnum -= 1 | 29 let lnum -= 1 |
29 else | 30 else |
30 break | 31 break |
31 endif | 32 endif |
32 else | 33 else |
33 break | 34 break |
34 endif | 35 endif |
35 endwhile | 36 endwhile |
43 let pattern = '[{}]' | 44 let pattern = '[{}]' |
44 let i = match(line, pattern) | 45 let i = match(line, pattern) |
45 while i != -1 | 46 while i != -1 |
46 if synIDattr(synID(a:lnum, i + 1, 0), 'name') !~ 'css\%(Comment\|StringQ\{1,2}\)' | 47 if synIDattr(synID(a:lnum, i + 1, 0), 'name') !~ 'css\%(Comment\|StringQ\{1,2}\)' |
47 if line[i] == '{' | 48 if line[i] == '{' |
48 let n_open += 1 | 49 let n_open += 1 |
49 elseif line[i] == '}' | 50 elseif line[i] == '}' |
50 if n_open > 0 | 51 if n_open > 0 |
51 let n_open -= 1 | 52 let n_open -= 1 |
52 else | 53 else |
53 let n_close += 1 | 54 let n_close += 1 |
54 endif | 55 endif |
55 endif | 56 endif |
56 endif | 57 endif |
57 let i = match(line, pattern, i + 1) | 58 let i = match(line, pattern, i + 1) |
58 endwhile | 59 endwhile |
59 return a:count_open ? n_open : n_close | 60 return a:count_open ? n_open : n_close |