Too light background for solaris scheme in Vim using zsh - vim

I want to use solarized, which gives a decent color scheme in Vim. It works by setting the 16 colors ansi colors in the gnome-terminal. It works fine if I use Vim from bash, but in zsh the colors are off. Some letters have the right background, but most have too light background. What is it about zsh that interferes with the ansi colors as displayed by Vim?

I can't reproduce this - if this is still an issue, perhaps giving relevant sections of ~/.bashrc, ~/.zshrc, ~/.vimrc etc might help.
I'm using the Solarized vim colorscheme, and the linked Gnome-Terminal settings in the following screenshots. As you can see, they appear to be identical - there's certainly no color issues in either zsh or vim that I've noticed (I don't use bash much).
My zsh settings are taken from oh-my-zsh, and my prompt is a hacked-up version of Phil!'s ZSH prompt (I have messed with the coloring of Phil!'s ZSH prompt, because it didn't play well with the Solarized iTerm2 colors). However, I do not think I've messed with anything that would affect the Solarized colorings between bash and zsh in vim. Certainly the vim settings are identical between the two screenshots below.

I had the same problem on Ubuntu 14 with zsh.
This fixed it (in the .vimrc)
let g:solarized_termcolors=256
set background=light
colorscheme solarized

I know this is a veeery old question but I had the same problem and came across this so I thought it could still be useful to someone if I answered it.
For me TERM was not set to xterm-256color in zsh like it was in bash so the colours were messed up in vim.
Simply adding export TERM=xterm-256color to the .zshrc file fixed the problem.

Related

airline.vim does not work inside tmux

I am new to tmux and also not an expert on VIM, I tried to use tmux these days, but seems that airline disappeared when I used vim inside tmux. I would like to show you the screen shots and hopefully anyone can help me solve this problem.
airline in vim
airline inside tmux
You need to correctly set $TERM environment variable to make vim properly detect 256 colors support by doing the following before opening vim:
export TERM=screen-256color
While the accepted answer works, it is not cheap. Manually setting the value of the $TERM variable will usually be set correctly by itself.
It is usually a good a idea to force tmux to assume the terminal supports 256 colors.
In your ~/.bash_aliases, add:
tmux='tmux -2'
Answer based on the following posts:
What is the difference between screen-256 color and xterm-256color
tmux vim colorscheme background is not showing
Add the following line in your .tmux.conf
set -g default-terminal screen-256color
In my case, using ubuntu 20.04 inside windows with WSL2, the accepted answer (export TERM=screen-256color), just freeze the tmux pane.
The fix for me was add to ~/.vim/vimrc:
set t_Co=256

Tmux does not show Vim colors properly (Ubuntu 14.04)

Searching around, I found that it might be a problem with Tmux detecting the correct terminal mode, so I placed this in my .tmux.conf:
set -g default-terminal "screen-256color"
Together with alias tmux="tmux -2" it makes some colorschemes work (badwolf for example), but not all of them (doesn't work for solarized, vividchalk and base16 for example). Since I wanted at least solarized, I installed it to gnome-terminal and to Vim. Colors show properly out of Tmux, but not in Tmux. I also set t_Co=256 (in Vim) but without success.
According to Tmux faq, there is nothing wrong with my configuration, but yet I can't get it to display properly. Any idea?
Update
To give a better understanding of the problem, below are some images.
First, Gvim (left) and Vim (right, in gnome-terminal):
Second, Vim (left, in gnome-terminal), Vim with tmux (right, also in gnome-terminal):
Credits: the code is from Princeton Algorithms course (authors: Robert Sedgewick and Kevin Wayne).
There are some steps required to solve this problem:
Install the solarized theme for gnome-terminal, found here.
Install the solarized theme for Vim (found here).
Create an alias for the tmux command or set the TERM variable as mentioned in ianks answer (in your .bashrc):
alias tmux="TERM=screen-256color-bce tmux"
Include the following line in your .tmux.conf:
set -g default-terminal "screen-256color"
I needed all these 4 steps to make my terminal colors show solarized. This post provides some other alternatives in case this doesn't work. One particular comment in that post helped the most, pointing to this resource.
It turns out that without setting the TERM variable, if you echo $TERM you see exactly what Tmux FAQ said you should (screen-256color), but you don't get the correct colors, don't know why.
Have you tried adding this to your .(*)shrc?
export TERM=screen-256color-bce
Back when I used gnome terminal this worked for me, but don't ask me why :)

Configuring solarized colorscheme in gnome terminal, tmux and vim

I'm struggling to make the Solarized colorscheme correctly working on an Ubuntu 13.10 machine inside Vim inside tmux inside the gnome-terminal.
I've started configuring gnome-terminal using the script on this repository and it displays the colors correctly. The same goes if I run Vim (with the official Solarized colorscheme) inside the terminal, without tmux.
Then I tried to configure tmux using this. It happens that when I run Vim the syntax highlight for php or javascript code is wrong or, at least, different from the one I see running Vim without tmux. I've tried also running tmux as tmux -2. The colors are different, but still the syntax highlight is not correct.
I tested it out and got it working in the following way:
Install gnome solarized colorscheme. You can get it from https://github.com/aruhier/gnome-terminal-colors-solarized.
Install solarized colorscheme for vim. You can get it from https://github.com/altercation/vim-colors-solarized. In .vimrc you should add following settings:
set t_Co=256
set background=dark
colorscheme solarized
Set correct TERM variable by adding following line to your .bashrc/.zshrc
export TERM=screen-256color-bce
Run gnome-terminal, tmux, vim and profit.
These days GNOME Terminal comes with Solarized colours built in. To use it, you need to change two settings in the profile that you're using. The obvious one is the text and background colour. You also need to set the palette to Solarized, though. You can find this setting below the one for the text and background colour. At this point, setting t_Co or g:solarized_termcolors in Vim shouldn't be necessary.
The palette is the part that I missed at first, which caused me to puzzle why the text in Vim and other applications was bright blue.

Vim color scheme not displaying properly

I downloaded the Dark.vim color scheme from here:
http://vimcolorschemetest.googlecode.com/svn/html/index-c.html (Click on Dark.vim to see the code)
Then put it in ~/.vim/colors.
I also did the same for 256-jungle.vim and af.vim.
:colorscheme Dark, :colorscheme af, etc. all work (i.e. they change vim's syntax highlighting) but none of them look like the screenshots in the link above.
Instead, they look like this (ordered af.vim, 256-jungle.vim, Dark.vim): http://imgur.com/a/NsmHy
At first I thought this might be a problem with the color-settings in my terminal, so I followed tips from a "256 colors in vim" Vim wiki-doc page, which told me to add the following to my ~/.bash_profile :
TERM=xterm-256color
# for enabling 256 color, as per http://vim.wikia.com/wiki/256_colors_in_vim
if [ -e /usr/share/terminfo/x/xterm-256color ]; then
export TERM='xterm-256color'
else
export TERM='xterm-color'
fi
This didn't work.
Also, here's what's in my ~/.vimrc file:
set tabstop=2
set t_Co=256
colorscheme 256-jungle
colorscheme Dark
syntax on
let $VIM='~/.vim/'
Any thoughts on what's causing this disparity between what the colorschemes "should" look like and what's actually being displayed in my terminal? I'm running Mac OS X 10.8.2.
Thanks in advance for any help.
The Dark colorscheme you tried to use in terminal is actually a scheme for GUI (if you take a look at it's code, you'll see only 'guifg, guibg' etc. definitions). To run gui colorschemes in a terminal you can try CSApprox plugin.

Issues with solarized and Terminal.app

I really apologize because I know that this question has been asked multiple times. I have gone through all of the previous questions, but I still have yet to have any luck setting up the Solarized colorscheme in my Terminal.app for OS X Mountain Lion. So far this is what I have:
My .vimrc currently is set up like the following:
set number
syntax enable
set background="dark"
colorscheme solarized
but for my MacVim I get this:
This is what I would like to have my Terminal.app display as well. The only thing that my .vimrc says for MacVim is
colorscheme solarized
Edit
After I had asked this question, I eventually moved to iTerm2, which proved to be much nicer.
I'm not 100% sure, but I think the newer versions of OS X terminal will support 256 colors out of the box.
I had the same issue, then I downloaded an alternate implementation of the Solarized theme for the Mountain Lion terminal, and this appears to have solved it.
Just add let g:solarized_termcolors=256 to your vimrc
Ensure that TERM is set to xterm-256color to let Vim know that the terminal supports 256 colors. This is the default for Terminal in Lion 10.7 and later†, so your preferences were customized at some point.
To tell Terminal to set TERM to a different value, go to
Terminal > Preferences > Settings > [profile] > Advanced
and change Declare terminal as: to xterm-256color.
[Note that all this preference does is set the value of the TERM environment variable. It does not alter the behavior of Terminal or affect what sort of terminal it emulates.]
† Prior to Lion, the default was xterm-color.
Add to your ~/.vimrc
" Solarized Dark
syntax enable
set t_Co=256
let g:solarized_termcolors=256
set background=dark
colorscheme solarized
This works on both ansi and xterm-256color versions of Solarized. Tested on Terminal 2.3 on a new OS X 10.8.5 VM installation.
NB This answer supersedes the previous one that proposed changes to the profile swatches. I recently realised I had these commands in my .vimrc file that actually configured Solarized.
To run vim with 256 colors you must use a 256 color terminal. You can set your terminal to xterm-256color, for example, with export TERM=xterm-256color and then start vim. You can export this $TERM setting in one of your terminal startup scripts (e.g. .bashrc, .zshrc, etc.).
It may seem counterintuitive, but use set g:solarized_termcolors=16. This is confirmed to be the correct setting with :h solarized.

Resources