Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions vim-colors-solarized/colors/solarized.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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.
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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 ."'"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down