annotate runtime/indent/css.vim @ 6303:7844d92941fd v7.4.485

updated for version 7.4.485 Problem: Abbreviations don't work. (Toothpik) Solution: Move the length computation inside the for loop. Compare against the unescaped key.
author Bram Moolenaar <bram@vim.org>
date Tue, 21 Oct 2014 19:35:31 +0200
parents 9cb3a75a20b9
children 1218c5353e2b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim indent file
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
2 " Language: CSS
839
1f3b1021f002 updated for version 7.0e05
vimboss
parents: 389
diff changeset
3 " Maintainer: Nikolai Weibull <now@bitwi.se>
3557
9cb3a75a20b9 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
4 " Latest Revision: 2012-05-30
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 setlocal indentexpr=GetCSSIndent()
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
12 setlocal indentkeys=0{,0},!^F,o,O
1189
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
13 setlocal nosmartindent
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14
3557
9cb3a75a20b9 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
15 let b:undo_indent = "setl smartindent< indentkeys< indentexpr<"
9cb3a75a20b9 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
16
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 if exists("*GetCSSIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 endif
3526
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2698
diff changeset
20 let s:keepcpo= &cpo
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2698
diff changeset
21 set cpo&vim
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
23 function s:prevnonblanknoncomment(lnum)
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
24 let lnum = a:lnum
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
25 while lnum > 1
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
26 let lnum = prevnonblank(lnum)
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
27 let line = getline(lnum)
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
28 if line =~ '\*/'
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
29 while lnum > 1 && line !~ '/\*'
1189
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
30 let lnum -= 1
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
31 endwhile
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
32 if line =~ '^\s*/\*'
1189
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
33 let lnum -= 1
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
34 else
1189
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
35 break
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
36 endif
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
37 else
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
38 break
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
39 endif
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
40 endwhile
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
41 return lnum
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
42 endfunction
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
43
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
44 function s:count_braces(lnum, count_open)
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
45 let n_open = 0
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
46 let n_close = 0
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
47 let line = getline(a:lnum)
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
48 let pattern = '[{}]'
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
49 let i = match(line, pattern)
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
50 while i != -1
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
51 if synIDattr(synID(a:lnum, i + 1, 0), 'name') !~ 'css\%(Comment\|StringQ\{1,2}\)'
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
52 if line[i] == '{'
1189
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
53 let n_open += 1
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
54 elseif line[i] == '}'
1189
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
55 if n_open > 0
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
56 let n_open -= 1
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
57 else
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
58 let n_close += 1
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
59 endif
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
60 endif
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
61 endif
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
62 let i = match(line, pattern, i + 1)
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
63 endwhile
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
64 return a:count_open ? n_open : n_close
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
65 endfunction
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
66
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
67 function GetCSSIndent()
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
68 let line = getline(v:lnum)
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
69 if line =~ '^\s*\*'
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
70 return cindent(v:lnum)
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
71 endif
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
72
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
73 let pnum = s:prevnonblanknoncomment(v:lnum - 1)
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
74 if pnum == 0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77
2698
b6471224d2af Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 1189
diff changeset
78 return indent(pnum) + s:count_braces(pnum, 1) * &sw
b6471224d2af Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 1189
diff changeset
79 \ - s:count_braces(v:lnum, 0) * &sw
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 endfunction
3526
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2698
diff changeset
81
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2698
diff changeset
82 let &cpo = s:keepcpo
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2698
diff changeset
83 unlet s:keepcpo