Skip to content

Commit 7d597ee

Browse files
committed
support for decimals and spaced color values
1 parent 3e7d1de commit 7d597ee

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

autoload/css_color.vim

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,13 @@ endfunction
230230
let s:_hexcolor = '#\(\x\{3}\%(\>\|\x\{3}\>\)\)' " submatch 1
231231
let s:_rgbacolor = '#\(\x\{3}\%(\>\|\x\%(\>\|\x\{2}\%(\>\|\x\{2}\>\)\)\)\)' " submatch 1
232232
let s:_funcname = '\(rgb\|hsl\)a\?' " submatch 2
233+
let s:_funcprep = '\%(\s*\S\+\%(\%(\s\+\S\+\)\{2}\|\%(\s*,\s*\S\+\)\{2}\)\)\@=' " lookahead for 12,34,56 vs 12 34 56 to avoid 12 34,56
233234
let s:_ws_ = '\s*'
234-
let s:_numval = s:_ws_ . '\([0-9]\{1,2}%\|100%\|1\?[0-9]\{1,2}\|2[0-4][0-9]\|25[0-5]\)' " submatch 3,4,5
235-
let s:_listsep = s:_ws_ . ','
236-
let s:_otherargs_ = '\%(,[^)]*\)\?'
237-
let s:_funcexpr = s:_funcname . '[(]' . s:_numval . s:_listsep . s:_numval . s:_listsep . s:_numval . s:_ws_ . s:_otherargs_ . '[)]'
235+
"let s:_numval = '\(\d\{1,3}\%(\.\d*\)\?%\?\)' " submatch 3,4,5 (use this after implementing ceilings for the output of b:css_color_pat)
236+
let s:_numval = '\(\d\{1,2}\%(\.\d*\)\?%\|100%\|255\|\%(1\?\d\{1,2}\|2[0-4]\d\|25[0-5]\)\%(\.\d*\)\?\)' " submatch 3,4,5
237+
let s:_listsep = s:_ws_ . '[,[:space:]]\+'
238+
let s:_otherargs_ = s:_ws_ . '\%([,\/][^)]*\)\?' " ignore alpha
239+
let s:_funcexpr = s:_funcname . '[(]' . s:_funcprep . s:_ws_ . s:_numval . s:_listsep . s:_numval . s:_listsep . s:_numval . s:_otherargs_ . '[)]'
238240
let s:_csscolor = s:_rgbacolor . '\|' . s:_funcexpr
239241
" N.B. sloppy heuristic constants for performance reasons:
240242
" a) start somewhere left of screen in case of partially visible colorref

0 commit comments

Comments
 (0)