Only check the term type for colors once rather than for each declaration, and when gui/termguicolors is not set then "set notermguicolors" should be run to get cterm colors working again in neovim 0.10+

This commit is contained in:
Kevin MacMartin 2024-08-07 00:32:39 -04:00
parent 5b5bfc3e96
commit 6d88ffd6a6
2 changed files with 16 additions and 14 deletions

View file

@ -19,30 +19,32 @@ endif
"declare the name of our theme "declare the name of our theme
let colors_name = "darkcloud" let colors_name = "darkcloud"
"declare the term type
if has("gui_running") || &termguicolors
let g:term_colors_type = "gui"
else
set notermguicolors "required to use cterm colors
let g:term_colors_type = "cterm"
endif
"sets the highlighting for the given group | format: s:C("Name","Foreground","Background","Style") "sets the highlighting for the given group | format: s:C("Name","Foreground","Background","Style")
fun! s:C(group, fg, bg, attr) fun! s:C(group, fg, bg, attr)
if has("gui_running") || &termguicolors
let l:term = "gui"
else
let l:term = "cterm"
endif
if a:fg != "" if a:fg != ""
exec "hi " . a:group . " " . l:term . "fg=" . a:fg exec "hi " . a:group . " " . g:term_colors_type . "fg=" . a:fg
else else
exec "hi " . a:group . " " . l:term . "fg=NONE" exec "hi " . a:group . " " . g:term_colors_type . "fg=NONE"
endif endif
if a:bg != "" if a:bg != ""
exec "hi " . a:group . " " . l:term . "bg=" . a:bg exec "hi " . a:group . " " . g:term_colors_type . "bg=" . a:bg
else else
exec "hi " . a:group . " " . l:term . "bg=NONE" exec "hi " . a:group . " " . g:term_colors_type . "bg=NONE"
endif endif
if a:attr != "" if a:attr != ""
exec "hi " . a:group . " " . l:term . "=" . a:attr exec "hi " . a:group . " " . g:term_colors_type . "=" . a:attr
else else
exec "hi " . a:group . " " . l:term . "=NONE" exec "hi " . a:group . " " . g:term_colors_type . "=NONE"
endif endif
endfun endfun

View file

@ -1,4 +1,4 @@
if has("gui_running") || &termguicolors if has("gui_running") || &term != "linux" && &termguicolors
let g:cBlack = '#000000' let g:cBlack = '#000000'
let g:cWhite = '#ffffff' let g:cWhite = '#ffffff'
@ -17,7 +17,7 @@ if has("gui_running") || &termguicolors
let g:cLightBg = '#303030' let g:cLightBg = '#303030'
let g:cDarkBg = '#262626' let g:cDarkBg = '#262626'
elseif &term != "linux" && &t_Co >= 256 elseif &t_Co >= 256 && &term != "linux"
let g:cBlack = '0' "#000000 let g:cBlack = '0' "#000000
let g:cWhite = '15' "#ffffff let g:cWhite = '15' "#ffffff