support for #aarrggbb format, close #28

This commit is contained in:
依云 2016-02-21 22:42:10 +08:00
parent acbffdc39a
commit 7999427668
2 changed files with 12 additions and 3 deletions

View file

@ -99,7 +99,7 @@ function! s:SetMatcher(color, pat) "{{{1
endif
endfunction
"i Color Converters {{{1
" Color Converters {{{1
function! s:RgbBgColor() "{{{2
let bg = synIDattr(synIDtrans(hlID("Normal")), "bg")
let r = str2nr(bg[1:2], 16)
@ -192,8 +192,13 @@ function! s:HexCode(str, lineno) "{{{2
let ha = tolower(foundcolor[7:8])
endif
if len(foundcolor) == 9
let alpha = foundcolor[7:8]
let foundcolor = foundcolor[0:6]
if get(g:, 'colorizer_hex_alpha_first') == 1
let alpha = foundcolor[1:2]
let foundcolor = '#'.foundcolor[3:8]
else
let alpha = foundcolor[7:8]
let foundcolor = foundcolor[0:6]
endif
else
let alpha = 'ff'
endif

View file

@ -33,6 +33,10 @@
" let g:colorizer_maxlines = 1000
" -1 means unlimited number of lines
"
" There are color strings in the format #RRGGBBAA and #AARRGGBB. The former is
" more common so it's the default. If you want the latter, set the following:
" let g:colorizer_hex_alpha_first = 1
"
" Note: if you modify a color string in normal mode, if the cursor is still on
" that line, it'll take 'updatetime' seconds to update. You can use
" :ColorHighlight (or your key mapping) again to force update.