Mercurial > vim
annotate runtime/indent/css.vim @ 31479:0c0b78aa7ae3 v9.0.1072
patch 9.0.1072: screenpos() column result in fold may be too small
Commit: https://github.com/vim/vim/commit/ba2d19193201277397c25c1f5a134ea042542555
Author: zeertzjq <zeertzjq@outlook.com>
Date: Sun Dec 18 12:28:59 2022 +0000
patch 9.0.1072: screenpos() column result in fold may be too small
Problem: screenpos() column result in fold may be too small.
Solution: Add space of 'number', sign column, etc. (closes https://github.com/vim/vim/issues/11715)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 18 Dec 2022 13:30:05 +0100 |
parents | 9c221ad9634a |
children |
rev | line source |
---|---|
7 | 1 " Vim indent file |
25880 | 2 " Language: CSS |
3 " Maintainer: Doug Kearns <dougkearns@gmail.com> | |
4 " Previous Maintainer: Nikolai Weibull <now@bitwi.se> | |
5 " Last Change: 24 Sep 2021 | |
6 | |
7 " Use of shiftwidth() added by Oleg Zubchenko. | |
7 | 8 |
9 if exists("b:did_indent") | |
10 finish | |
11 endif | |
12 let b:did_indent = 1 | |
13 | |
14 setlocal indentexpr=GetCSSIndent() | |
375 | 15 setlocal indentkeys=0{,0},!^F,o,O |
1189 | 16 setlocal nosmartindent |
7 | 17 |
25880 | 18 let b:undo_indent = "setl inde< indk< si<" |
3557 | 19 |
7 | 20 if exists("*GetCSSIndent") |
21 finish | |
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 | 25 |
389 | 26 function s:prevnonblanknoncomment(lnum) |
27 let lnum = a:lnum | |
28 while lnum > 1 | |
29 let lnum = prevnonblank(lnum) | |
375 | 30 let line = getline(lnum) |
31 if line =~ '\*/' | |
389 | 32 while lnum > 1 && line !~ '/\*' |
1189 | 33 let lnum -= 1 |
375 | 34 endwhile |
389 | 35 if line =~ '^\s*/\*' |
1189 | 36 let lnum -= 1 |
389 | 37 else |
1189 | 38 break |
389 | 39 endif |
40 else | |
41 break | |
375 | 42 endif |
43 endwhile | |
44 return lnum | |
45 endfunction | |
46 | |
389 | 47 function s:count_braces(lnum, count_open) |
48 let n_open = 0 | |
49 let n_close = 0 | |
50 let line = getline(a:lnum) | |
51 let pattern = '[{}]' | |
52 let i = match(line, pattern) | |
53 while i != -1 | |
54 if synIDattr(synID(a:lnum, i + 1, 0), 'name') !~ 'css\%(Comment\|StringQ\{1,2}\)' | |
55 if line[i] == '{' | |
1189 | 56 let n_open += 1 |
389 | 57 elseif line[i] == '}' |
1189 | 58 if n_open > 0 |
59 let n_open -= 1 | |
60 else | |
61 let n_close += 1 | |
62 endif | |
389 | 63 endif |
64 endif | |
65 let i = match(line, pattern, i + 1) | |
66 endwhile | |
67 return a:count_open ? n_open : n_close | |
68 endfunction | |
69 | |
375 | 70 function GetCSSIndent() |
389 | 71 let line = getline(v:lnum) |
72 if line =~ '^\s*\*' | |
73 return cindent(v:lnum) | |
74 endif | |
75 | |
76 let pnum = s:prevnonblanknoncomment(v:lnum - 1) | |
77 if pnum == 0 | |
7 | 78 return 0 |
79 endif | |
80 | |
11062 | 81 return indent(pnum) + s:count_braces(pnum, 1) * shiftwidth() |
82 \ - s:count_braces(v:lnum, 0) * shiftwidth() | |
7 | 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 |