annotate runtime/indent/css.vim @ 29064:3fbc7462de59 v8.2.5054

patch 8.2.5054: no good filetype for conf files similar to dosini Commit: https://github.com/vim/vim/commit/635f48010dcf6d97f3a65b4785e1726ad386d3eb Author: Mudskipper875 <89634034+Mudskipper875@users.noreply.github.com> Date: Fri Jun 3 18:40:53 2022 +0100 patch 8.2.5054: no good filetype for conf files similar to dosini Problem: No good filetype for conf files similar to dosini. Solution: Add the confini filetype. (closes https://github.com/vim/vim/issues/10510)
author Bram Moolenaar <Bram@vim.org>
date Fri, 03 Jun 2022 19:45:02 +0200
parents 9c221ad9634a
children
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
25880
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
2 " Language: CSS
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
3 " Maintainer: Doug Kearns <dougkearns@gmail.com>
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
4 " Previous Maintainer: Nikolai Weibull <now@bitwi.se>
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
5 " Last Change: 24 Sep 2021
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
6
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
7 " Use of shiftwidth() added by Oleg Zubchenko.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 setlocal indentexpr=GetCSSIndent()
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
15 setlocal indentkeys=0{,0},!^F,o,O
1189
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
16 setlocal nosmartindent
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
25880
9c221ad9634a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
18 let b:undo_indent = "setl inde< indk< si<"
3557
9cb3a75a20b9 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
19
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 if exists("*GetCSSIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 endif
3526
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2698
diff changeset
23 let s:keepcpo= &cpo
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2698
diff changeset
24 set cpo&vim
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
26 function s:prevnonblanknoncomment(lnum)
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
27 let lnum = a:lnum
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
28 while lnum > 1
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
29 let lnum = prevnonblank(lnum)
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
30 let line = getline(lnum)
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
31 if line =~ '\*/'
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
32 while lnum > 1 && line !~ '/\*'
1189
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
33 let lnum -= 1
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
34 endwhile
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
35 if line =~ '^\s*/\*'
1189
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
36 let lnum -= 1
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
37 else
1189
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
38 break
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
39 endif
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
40 else
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
41 break
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
42 endif
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
43 endwhile
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
44 return lnum
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
45 endfunction
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
46
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
47 function s:count_braces(lnum, count_open)
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
48 let n_open = 0
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
49 let n_close = 0
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
50 let line = getline(a:lnum)
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
51 let pattern = '[{}]'
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
52 let i = match(line, pattern)
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
53 while i != -1
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
54 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
55 if line[i] == '{'
1189
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
56 let n_open += 1
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
57 elseif line[i] == '}'
1189
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
58 if n_open > 0
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
59 let n_open -= 1
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
60 else
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
61 let n_close += 1
7cdd85615e4e updated for version 7.1b
vimboss
parents: 856
diff changeset
62 endif
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
63 endif
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
64 endif
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
65 let i = match(line, pattern, i + 1)
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
66 endwhile
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
67 return a:count_open ? n_open : n_close
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
68 endfunction
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
69
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
70 function GetCSSIndent()
389
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
71 let line = getline(v:lnum)
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
72 if line =~ '^\s*\*'
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
73 return cindent(v:lnum)
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
74 endif
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
75
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
76 let pnum = s:prevnonblanknoncomment(v:lnum - 1)
4fe8e1a7758e updated for version 7.0102
vimboss
parents: 375
diff changeset
77 if pnum == 0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80
11062
1218c5353e2b Runtime file updates.
Christian Brabandt <cb@256bit.org>
parents: 3557
diff changeset
81 return indent(pnum) + s:count_braces(pnum, 1) * shiftwidth()
1218c5353e2b Runtime file updates.
Christian Brabandt <cb@256bit.org>
parents: 3557
diff changeset
82 \ - s:count_braces(v:lnum, 0) * shiftwidth()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 endfunction
3526
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2698
diff changeset
84
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2698
diff changeset
85 let &cpo = s:keepcpo
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2698
diff changeset
86 unlet s:keepcpo