Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

termguicolors in vim makes everything black and white

Tags:

vim

The idea is that by using set termguicolors in Vim, I should get the colorscheme (gruvbox) to look in my terminal (st, has true color support) exactly like in GVim. But all I get is white text on black background.

The part in vimrc which sets the colorscheme:

set background=dark
colorscheme gruvbox
set termguicolors
like image 457
Тельман Бабаев Avatar asked Jul 02 '20 18:07

Тельман Бабаев


1 Answers

You might read :h xterm-true-color.

I'm using st as well, and indeed, setting termguicolors gave me black and white colors only.

But by following the advice in the help, I added the following:

let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"

Then colors appeared again. Hope it can help.

Here is the whole excerpt from :h xterm-true-color:

Vim supports using true colors in the terminal (taken from |highlight-guifg| and |highlight-guibg|), given that the terminal supports this. To make this work the 'termguicolors' option needs to be set. See https://gist.github.com/XVilka/8346728 for a list of terminals that support true colors.

Sometimes setting 'termguicolors' is not enough and one has to set the |t_8f| and |t_8b| options explicitly. Default values of these options are "^[[38;2;%lu;%lu;%lum" and "^[[48;2;%lu;%lu;%lum" respectively, but it is only set when $TERM is xterm. Some terminals accept the same sequences, but with all semicolons replaced by colons (this is actually more compatible, but less widely supported):

     let &t_8f = "\<Esc>[38:2:%lu:%lu:%lum"
     let &t_8b = "\<Esc>[48:2:%lu:%lu:%lum"

These options contain printf strings, with |printf()| (actually, its C equivalent hence l modifier) invoked with the t_ option value and three unsigned long integers that may have any value between 0 and 255 (inclusive) representing red, green and blue colors respectively.

like image 153
yolenoyer Avatar answered Nov 20 '22 06:11

yolenoyer