From c4e3925bce1702a73cc50fc8cf376d3ff05d20ef Mon Sep 17 00:00:00 2001 From: pi-rho Date: Tue, 9 Apr 2024 18:38:36 -0600 Subject: [PATCH] Honor termguicolors and terminals with t_co > 256. Fixes: #186 --- autoload/css_color.vim | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/autoload/css_color.vim b/autoload/css_color.vim index d037f31..98cb02a 100644 --- a/autoload/css_color.vim +++ b/autoload/css_color.vim @@ -3,14 +3,25 @@ " Commit: $Format:%H$ " Licence: The MIT License (MIT) -if ! ( v:version >= 700 && has('syntax') && ( has('gui_running') || has('nvim') || &t_Co == 256 ) ) +if ! ( v:version >= 700 && has('syntax') && ( + \ has('gui_running') || + \ has('nvim') || + \ (has('termguicolors') && &termguicolors) || + \ &t_Co >= 256 + \ ) ) function! css_color#init(type, keywords, groups) endfunction function! css_color#extend(groups) endfunction + function! css_color#disabled() + return v:true + endfunction finish endif +function! css_color#disabled() + return v:false +endfunction function! s:rgb2color(r,g,b) " Convert 80% -> 204, 100% -> 255, etc. let rgb = map( [a:r,a:g,a:b], 'v:val =~ "%$" ? ( 255 * v:val ) / 100 : v:val' )