Ubuntu, Vim, and the solarized color palette - vim

I'd really like to get in on all the colorful goodness of the solarized colorscheme, but I can't seem to get it configured just right.
I have the main solarized file in my .vim/colors folder, I've set my terminal profile colors to what is listed on the site, and I've added the lines
set background=dark
let g:solarized_termcolors=16
colorscheme solarized
to my .vimrc file, but Vim looks greyed out and is using a bright green color as the default. How can I do it?

Here's my recommendation for things to try:
ensure syntax on is in your .vimrc file
Check what t_Co Vim has picked up from your term emulator (a quick :echo &t_Co). If it's 8, you'll want to se t_Co=16. You might also try se t_Co=256 though without let g:solarized_termcolors=16 this will use the 256 fallback mode, which isn't quite the correct color scheme.

set t_Co=16 and let g:solarized_termcolors=16 did not work for me. This is what worked:
syntax on
let g:solarized_termcolors=256
set t_Co=256
set background=dark
colorscheme solarized

I found out how do do it from this article.
I wrote the following script to do the gnome-terminal stuff.
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/use_theme_background" --type bool false
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/use_theme_colors" --type bool false
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/palette" --type string "#070736364242:#D3D301010202:#858599990000:#B5B589890000:#26268B8BD2D2:#D3D336368282:#2A2AA1A19898:#EEEEE8E8D5D5:#00002B2B3636:#CBCB4B4B1616:#58586E6E7575:#65657B7B8383:#838394949696:#6C6C7171C4C4:#9393A1A1A1A1:#FDFDF6F6E3E3"
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/background_color" --type string "#00002B2B3636"
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/foreground_color" --type string "#838394949696"

If you are trying to use Vim with solarized inside of tmux, this is the fix for your issue:
Fix solarized theme in tmux

Trying it out myself, it seems to work better without the
let g:solarized_termcolors=16
Setting it to 16, I get the bright green color you seem to describe. Maybe try leaving it at the default of 256?
This doesn't, however, perfectly mimic the colors from the screenshots (although the light version looks fairly close). I only get the colors with the screenshot if I use gVim.
I didn't use the terminal profile colors provided, however, so you may get a different result.

For the copy and paste lovers, this is how you install the solarized Vim colorscheme on Ubuntu:
sudo apt-get install wget unzip curl
cd
wget http://ethanschoonover.com/solarized/files/solarized.zip
unzip solarized.zip
mkdir .vim
mkdir .vim/colors/
mv solarized/vim-colors-solarized/colors/solarized.vim ~/.vim/colors/
cp .vimrc .vimrc.old
echo "syntax enable" > .vimrc
echo "set background=dark" >> .vimrc
echo "colorscheme solarized" >> .vimrc
curl https://raw.github.com/seebi/dircolors-solarized/master/dircolors.256dark > ~/.dircolors
source .bashrc
rm -r solarized
rm solarized.zip
And presto.

From the README (emphasis mine):
IMPORTANT NOTE FOR TERMINAL USERS:
If you are going to use Solarized in Terminal mode (i.e. not in a GUI
version like gvim or macvim), please please please consider
setting your terminal emulator's colorscheme to used the Solarized
palette. I've included palettes for some popular terminal emulator as
well as Xdefaults in the official Solarized download available from
[Solarized homepage]. If you use Solarized without these colors,
Solarized will need to be told to degrade its colorscheme to a set
compatible with the limited 256 terminal palette (whereas by using
the terminal's 16 ansi color values, you can set the correct, specific
values for the Solarized palette).
If you do use the custom terminal colors, solarized.vim should work
out of the box for you. If you are using a terminal emulator that
supports 256 colors and don't want to use the custom Solarized
terminal colors, you will need to use the degraded 256 colorscheme.
To do so, simply add the following line before the colorschem solarized line:
let g:solarized_termcolors=256
Again, I recommend just changing your terminal colors to Solarized
values either manually or via one of the many terminal schemes
available for import.
Simply selecting Solarized for both "Text and Background Color" (choose light or dark) and "Palette" in Terminal → Preferences → Profiles → (select yours) → Edit → Colors worked for me on Ubuntu 16.04 (Xenial Xerus) with the included Terminal application.
Some other answers recommend choosing a 256 color palette but, as mentioned in the documentation, this gives you a degraded (and visibly worse in my opinion) color scheme.

This worked for me for exherbo
git clone https://github.com/sigurdga/gnome-terminal-colors-solarized
cd gnome-terminal-colors-solarized
sh install.sh -s dark -p <my_current_profile>
256 colors in vim may also help

Related

Setting up onedark as a colorscheme in Vim?

I'm trying to set up my color scheme on vim using onedark
I've cloned the repository and ran the following commands:
$ git clone https://github.com/joshdick/onedark.vim.git ~/onedark
$ cd ~/onedark
$ mkdir ~/.vim/colors
$ cp colors/onedark.vim ~/.vim/colors/
$ cp autoload/onedark.vim ~/.vim/autoload/
My .vimrc contains a few settings and I added
syntax on
colorscheme onedark
But my editor still shows like this:
Am I missing something?
You need to put this to your vimrc:
" Turns on syntax highlighting
syntax on
if has('termguicolors')
" Turns on true terminal colors
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
" Turns on 24-bit RGB color support
set termguicolors
" Defines how many colors should be used. (maximum: 256, minimum: 0)
set t_Co=256
endif
set background=dark
colorscheme onedark
However, if you want Color scheme work well you have to install any syntax highlighter, such as (most popular):
nvim-treesitter for NeoVim
vim-polyglot for Vim.
Or, you can configure tree-sitter manually for Vim.
If you use Vim in a terminal, you will also have to install the appropriate color scheme for your terminal. For example, if you use iTerm then you will have to download and install the One Dark.itermcolors color scheme.
I advice you to read the Troubleshooting section, as there may be other issues with your setup.

vim/terminal highlighting conditionals

I am just trying to set up vim such that I get the colors I prefer.
I created a ~.vimrc file and set syntax on
I then went Terminal > Preferences > Profile > Text and have been changing the ANSI colors such that the file looks the way I want
Unfortunately I have come across the problem that conditionals (if, else, and so on) are not using any of the ANSI colors and I therefore cannot change my preferences this way.
I have been looking in the vim syntax located at /usr/share/vim/vim73/syntax to see how this is implemented. I see where these are grouped, but cannot seem to find where the colors are assigned and why I cannot overwrite just this in my preferences.
where am I able to go to find this code, and what are some of the options for customizing this
NOTE
I am on Mac Yosemite 10.10.5
There are many colorscheme available. My favourite colorscheme to highlight the keywords is gruvbox following are the steps to install.
installing pathogen
mkdir -p ~/.vim/autoload ~/.vim/bundle
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
installing the colorscheme gruvbox
git clone https://github.com/morhetz/gruvbox.git ~/.vim/bundle/gruvbox
add the following to your ~/.vimrc file
execute pathogen#infect()
colorscheme gruvbox
set background=dark " Setting dark mode

Vim theme light solarized doesn't work with xfce4-terminal, even with terminal theme

I'm trying to use the light solarized theme with vim and xfce4-terminal.
I installed the theme for xfce4-terminal:
cd
mkdir solarized ; cd solarized
git clone https://github.com/sgerrand/xfce4-terminal-colors-solarized.git
cp xfce4-terminal-colors-solarized/light/terminalrc ~/.config/xfce4/terminal/
Apparently it works fine. However, when I use vim, the colors are different from the expected:
Gvim presents the correct colors. Konsole (with the proper theme, from the same git repository) shows the correct colors too.
The dark theme is presented correctly if change the vim and the xfce4-terminal theme.
I tried to change TERM and t_Co, but it didn't work.
I tried to follow this answer but it remains with the incorrect colors.
The link above says that the xfce4-terminal devs have changed the syntax of terminalrc.
When I compare xfce4-terminal and konsole pallets, I see that the there are some colors different, so I think terminal isn't reading rightly the terminalrc archive. Since the terminalrc archive from git is 2 years old, it makes sense. However, I don't know how to modify to the correct colors since I don't know the correspondence between the pallets of Konsoleand Xfce.
Does anyone have a suitable archive? Does anyone want to create one and make it available via git, updating the config for other people? (presuming that it's in fact a problem with the recent syntax.)
oK got it work!
You cannot use the colors which are on git hub xfce4-terminal
For the dark you can use the one which comes with xfce-terminal (Edit->Properties->Color->Presets * Solarized (dark/light)
Important is that you go afterwards to ~/.config/xfce4/terminal/terminalrc and remove
ColorCursor=
Than edit the .vimrc with
syntax enable
set background=dark
colorscheme solarized
set t_Co=16
set background=dark works for me with light and dark terminal setting.
I have exactly the same problem.
I get the best results with this.
It is not 100% the same but looks best to me
let g:solarized_termcolors=256
syntax enable
set background=light
colorscheme solarized
set t_Co=256
Hope that helps

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