VIM: How to configure Solarized colorscheme in Konsole

10

5

I am trying to configure Solarized for use in VIM in Konsole (KDE terminal). This is the result that I get: Konsole with Solarized

Note that Solarized looks fine in GVIM on the same machine: GVIM with Solarized

I suspect that it is Konsole's profile (colorscheme) that is the problem, but I do not see how to configure Konsole properly. I tried to use the Solarized .Xresources file hoping that would improve Konsole support, but it did not.

dotancohen

Posted 2012-05-12T16:34:41.503

Reputation: 9 798

Answers

6

The theme works fine in gVIM because gVIM supports 16.7 million colors, the Solarized colors being among them.

In the terminal, Solarized will use the 16 default ANSI terminal colors. This will look terrible unless you install the Solarized theme for your terminal emulator. There are many versions available for Konsole, you should browse around and pick the most accurate one. Once installed, the theme will replace the 16 ANSI colors (usually quite plain) with the Solarized ones, 'Solarizing' your whole terminal (or rather any application with color).

The alternative is to tell Solarized to 'degrade' to the basic 256-color palette that many terminal emulators support. The colors you get will not represent the true Solarized colors, but are an approximation. You can enable the degraded 256-color version of Solarized by adding let g:solarized_termcolors=256 to your .vimrc file.

Also, if the degraded colors STILL don't show up, add Daniel Andersson's answer to mine, and add set t_Co=256 to your .vimrc. (this should not be necessary if your $TERM is properly set, it should probably be xterm-256color)

neersighted

Posted 2012-05-12T16:34:41.503

Reputation: 1 206

4Thank you. Adding let g:solarized_termcolors=256 to .vimrc resolved the issue. – dotancohen – 2012-06-26T10:31:31.473

4

Mostly, follow http://vim.wikia.com/wiki/256_colors_in_vim.

In short:

  • Does the 256 color support work correctly in your terminal? Run some 256 color test (I use this script).
  • Is your $TERM value correctly set? The Vim wiki suggests TERM=konsole-256color for Konsole.
  • A correct term should set an equivalent to set t_Co=256 in Vim; you can also try setting this yourself (in the ~/.vimrc, before the color scheme is loaded).

Hopefully this can eliminate some error possibilities at least.

Daniel Andersson

Posted 2012-05-12T16:34:41.503

Reputation: 20 465

Clever script, thanks! It shows that all the colours work as intended. TERM was xterm-256color but even setting it to konsole-256color and then launching VIM did not help. Also, running :set t_Co=246 in the running VIM did not help either. – dotancohen – 2012-05-12T18:09:20.857