[vim] use true-color RGB in the terminal when 'termguicolors' is set

This commit is contained in:
Darsey Litzenberger 2022-10-04 22:40:21 -06:00
parent 62f656a02f
commit fd52e14336

View file

@ -134,6 +134,13 @@
" Allow or disallow certain features based on current terminal emulator or
" environment.
" Some terminals support RGB color
if has("gui_running") || exists("&termguicolors") && &termguicolors
let s:use_guicolors = 1
else
let s:use_guicolors = 0
endif
" Terminals that support italics
let s:terms_italic=[
\"rxvt",
@ -145,7 +152,7 @@ let s:terms_noitalic=[
\"iTerm.app",
\"Apple_Terminal"
\]
if has("gui_running")
if s:use_guicolors
let s:terminal_italic=1 " TODO: could refactor to not require this at all
else
let s:terminal_italic=0 " terminals will be guilty until proven compatible
@ -240,7 +247,7 @@ let colors_name = "solarized"
" leave the hex values out entirely in that case and include only cterm colors)
" We also check to see if user has set solarized (force use of the
" neutral gray monotone palette component)
if (has("gui_running") && g:solarized_degrade == 0)
if (s:use_guicolors && g:solarized_degrade == 0)
let s:vmode = "gui"
let s:base03 = "#002b36"
let s:base02 = "#073642"
@ -259,7 +266,7 @@ if (has("gui_running") && g:solarized_degrade == 0)
let s:cyan = "#2aa198"
"let s:green = "#859900" "original
let s:green = "#719e07" "experimental
elseif (has("gui_running") && g:solarized_degrade == 1)
elseif (s:use_guicolors && g:solarized_degrade == 1)
" These colors are identical to the 256 color mode. They may be viewed
" while in gui mode via "let g:solarized_degrade=1", though this is not
" recommened and is for testing only.
@ -368,7 +375,7 @@ endif
"}}}
" Background value based on termtrans setting "{{{
" ---------------------------------------------------------------------
if (has("gui_running") || g:solarized_termtrans == 0)
if (s:use_guicolors || g:solarized_termtrans == 0)
let s:back = s:base03
else
let s:back = "NONE"
@ -490,7 +497,7 @@ exe "let s:fmt_revb = ' ".s:vmode."=NONE".s:r.s:b. " term=NONE".s:r.s:b."'"
exe "let s:fmt_revbb = ' ".s:vmode."=NONE".s:r.s:bb. " term=NONE".s:r.s:bb."'"
exe "let s:fmt_revbbu = ' ".s:vmode."=NONE".s:r.s:bb.s:u." term=NONE".s:r.s:bb.s:u."'"
if has("gui_running")
if s:use_guicolors
exe "let s:sp_none = ' guisp=".s:none ."'"
exe "let s:sp_back = ' guisp=".s:back ."'"
exe "let s:sp_base03 = ' guisp=".s:base03 ."'"
@ -620,7 +627,7 @@ exe "hi! MoreMsg" .s:fmt_none .s:fg_blue .s:bg_none
exe "hi! ModeMsg" .s:fmt_none .s:fg_blue .s:bg_none
exe "hi! LineNr" .s:fmt_none .s:fg_base01 .s:bg_base02
exe "hi! Question" .s:fmt_bold .s:fg_cyan .s:bg_none
if ( has("gui_running") || &t_Co > 8 )
if ( s:use_guicolors || &t_Co > 8 )
exe "hi! VertSplit" .s:fmt_none .s:fg_base00 .s:bg_base00
else
exe "hi! VertSplit" .s:fmt_revbb .s:fg_base00 .s:bg_base02
@ -642,7 +649,7 @@ exe "hi! DiffChange" .s:fmt_undr .s:fg_yellow .s:bg_none .s:sp_yellow
exe "hi! DiffDelete" .s:fmt_bold .s:fg_red .s:bg_none
exe "hi! DiffText" .s:fmt_undr .s:fg_blue .s:bg_none .s:sp_blue
else " normal
if has("gui_running")
if s:use_guicolors
exe "hi! DiffAdd" .s:fmt_bold .s:fg_green .s:bg_base02 .s:sp_green
exe "hi! DiffChange" .s:fmt_bold .s:fg_yellow .s:bg_base02 .s:sp_yellow
exe "hi! DiffDelete" .s:fmt_bold .s:fg_red .s:bg_base02