Mercurial > vim
annotate runtime/indent/css.vim @ 6262:452e8b2a0ab3 v7.4.465
updated for version 7.4.465
Problem: Crash when expanding a very long string.
Solution: Use wsncpy() instead of wcscpy(). (Ken Takata)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Tue, 07 Oct 2014 10:38:40 +0200 |
parents | 9cb3a75a20b9 |
children | 1218c5353e2b |
rev | line source |
---|---|
7 | 1 " Vim indent file |
389 | 2 " Language: CSS |
839 | 3 " Maintainer: Nikolai Weibull <now@bitwi.se> |
3557 | 4 " Latest Revision: 2012-05-30 |
7 | 5 |
6 if exists("b:did_indent") | |
7 finish | |
8 endif | |
9 let b:did_indent = 1 | |
10 | |
11 setlocal indentexpr=GetCSSIndent() | |
375 | 12 setlocal indentkeys=0{,0},!^F,o,O |
1189 | 13 setlocal nosmartindent |
7 | 14 |
3557 | 15 let b:undo_indent = "setl smartindent< indentkeys< indentexpr<" |
16 | |
7 | 17 if exists("*GetCSSIndent") |
18 finish | |
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 | 22 |
389 | 23 function s:prevnonblanknoncomment(lnum) |
24 let lnum = a:lnum | |
25 while lnum > 1 | |
26 let lnum = prevnonblank(lnum) | |
375 | 27 let line = getline(lnum) |
28 if line =~ '\*/' | |
389 | 29 while lnum > 1 && line !~ '/\*' |
1189 | 30 let lnum -= 1 |
375 | 31 endwhile |
389 | 32 if line =~ '^\s*/\*' |
1189 | 33 let lnum -= 1 |
389 | 34 else |
1189 | 35 break |
389 | 36 endif |
37 else | |
38 break | |
375 | 39 endif |
40 endwhile | |
41 return lnum | |
42 endfunction | |
43 | |
389 | 44 function s:count_braces(lnum, count_open) |
45 let n_open = 0 | |
46 let n_close = 0 | |
47 let line = getline(a:lnum) | |
48 let pattern = '[{}]' | |
49 let i = match(line, pattern) | |
50 while i != -1 | |
51 if synIDattr(synID(a:lnum, i + 1, 0), 'name') !~ 'css\%(Comment\|StringQ\{1,2}\)' | |
52 if line[i] == '{' | |
1189 | 53 let n_open += 1 |
389 | 54 elseif line[i] == '}' |
1189 | 55 if n_open > 0 |
56 let n_open -= 1 | |
57 else | |
58 let n_close += 1 | |
59 endif | |
389 | 60 endif |
61 endif | |
62 let i = match(line, pattern, i + 1) | |
63 endwhile | |
64 return a:count_open ? n_open : n_close | |
65 endfunction | |
66 | |
375 | 67 function GetCSSIndent() |
389 | 68 let line = getline(v:lnum) |
69 if line =~ '^\s*\*' | |
70 return cindent(v:lnum) | |
71 endif | |
72 | |
73 let pnum = s:prevnonblanknoncomment(v:lnum - 1) | |
74 if pnum == 0 | |
7 | 75 return 0 |
76 endif | |
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 | 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 |