Solarized theme on Vim + Terminator + Ubuntu 11.10 - vim

I am trying to setup solarized theme for vim on Terminator but it is not working. :-(
I was successfully able to setup solarized for terminator but it just doesn't seem to work for vim. Here is what my .vimrc looks like
call pathogen#infect()
filetype plugin indent on
syntax enable
set background=dark
"set t_Co=16
"let g:solarized_termcolors=16
let g:solarized_visibility = "high"
let g:solarized_contrast = "high"
colorscheme solarized
$TERM is set to xterm
I have also tried it with the two lines above uncommented but still not working.
Could someone please tell me what I am doing wrong?
Thanks!
Edit:

As Ethan Schoonover pointed out in his vim colorscheme readme, to make the colorscheme work first you have to configure your terminal colour palette.
In terminator there is a github repo that holds the colour configuration for the dark and light scheme.
The problem is that that palette isn't right either :P, the correct one is the one a guy posted in an issue on that same repo.
The correct configuration is the following (at least for the dark scheme):
[[solarized-dark]]
palette = "#073642:#dc322f:#859900:#b58900:#268bd2:#d33682:#2aa198:#eee8d5:#002b36:#cb4b16:#586e75:#657b83:#839496:#6c71c4:#93a1a1:#fdf6e3"
cursor_color = "#eee8d5"
foreground_color = "#eee8d5"
background_color = "#002b36"
After that, you have to configure the solarized colorscheme:
syntax on
set t_Co=16
set background=dark
colorscheme solarized
A couple of things to have in mind:
Normally, the set t_Co=16 line is not necessary because most terminal emulators only support 16 colours (terminator for example). But I rather be explicit than implicit (specially if you are going to sync your files between multiple computers).
The line set g:solarized_termcolors=16 is the default, so you can put it or not: it won't make any difference.
In my experience the 256 colour version is better (I like more grey background over a blue one; but that's personal taste :P). Contrary to what everyone could think, the 256 colour scheme is actually the 'fallback' being the 16 one the default. Yeah, weird, most people would think that 256 > 16. Anyway, to use the 'fallback' you have to change the lines to the following:
set t_Co=256
set g:solarized_termcolors=256
There are actually some issues with colour output in other CLI applications, I suggest you to go and read Seebi article about dircolors and an ongoing(?) discussion on the solarized github issue tracker.

Pretty sure you don't need the vim color theme import, since you already set up the color scheme for terminator. At least, that was the only way I could get it to play nice after lots of trial and error.
Here's a screenshot of my vimrc, from vim, within terminator:
As you can see, I haven't got the line
colorscheme solarized
So you could try taking that out - it finally seems to be working for me!
ps your screenshot doesn't look like it was taken from within terminator - unless we are talking about different terminators, of course.

Try adding this to your .vimrc file
let g:solarized_termcolors=16
The rest of the settings in the screenshot are fine.

Related

set background=dark in .vimrc does not change vims background

I added set background=dark in my .vimrc but my vim is still with a light background.
Am I missing something? Do I have to compile something so that my changes are used?
Edit:
I am Using a Debian Stretch distribution and I had to reinstall vim, because I failed to use SpaceVim, but this Problem occured before as well.
I have also noticed this text in .viminfo:
:set background=dark
|2,0,1555...47,,"set background=dark"
I don't understand this snippet but I guess that this would not hinder vim to get the setting out of .vimrc(?)
http://vimdoc.sourceforge.net/htmldoc/options.html#%27background%27
When set to "dark" or "light", Vim will try to use colors that look good on a dark (or light) background.
Setting this option does not change the background color, it tells Vim what the background color looks like.

Vim Issue With Changing Color Schemes

I originally used the colorscheme Solarized Dark, which worked completely fine. I also used the correct iTerm2 theme to go along with it. Then, I made a switch to the Gruvbox colorscheme, and I switched to the GruvBox iTerm2 theme to go with that. This also worked fine.
My problem occurred when I attempted to switch back to the Solarized Dark color scheme. I would post images if I could, but here's what the relevant section of my .vimrc is:
set t_Co=256
syntax enable " enable syntax processing
"Solarized Settings
let g:solarized_termcolors=256
set background=dark
colorscheme solarized
These are the same settings I used when I first used the Solarized color scheme, and they worked fine.
But now, it looks like maybe the syntax colors are correct, but the background is pretty much black. And even if I add the let g:solarized_transcolors=1 settings (which I never had to do before), which fixes the black background, the line number column, as well as buffer header (on top), also have black backgrounds.
Any insight into this issue would be appreciated. Note that I have also tried with a completely fresh .vimrc file and .vim folder, yet I still ran into the same problem, so I don't think this can be because of any conflicts among color schemes.
My suspicion is that the vim program is somehow storing old background colors it uses and prevents them from changing.

Trouble Getting Colorschemes in Vim with Iterm2

I can't get the vimbrant colorscheme (or any) to work in Vim with Iterm2. This is my .vimrc file:
syntax on
syntax enable
colorscheme vimbrant
set background=dark
I have Iterm set up to use xterm-256 like it says in the FAQ as well. Whenever I echo in Vim it says 256.
The terminal also doesn't use the color settings I have in Iterm2 but I don't care about that as much.
EDIT: The file is in ~/.vim/colors/vimbrant.vim. Also, I forgot to mention that my cursor seems to have the right colors for variables and structs and whatnot, but the text itself is all white still. The background seems to be the correct color. And the only thing in my .gvimrc file is colorscheme vimbrant.
Really dumb mistake, I had minimum contrast maxed out without realizing.
I've been having the same issue and this is what seems to have solved it:
In your .bash_profile set CLICOLOR before setting TERM:
# Set CLICOLOR if you want Ansi Colors in iTerm2
export CLICOLOR=1
# Set colors to match iTerm2 Terminal Colors
export TERM=xterm-256color
save bash file and source:
source ~/.bash_profile
Then, in your iTerm2 Preferences > Terminal > Report Terminal Type, set to either xterm-256color or xterm
Close iTerm2, restart it and type ls. That did the trick for me.
Good luck.
I have my iterm2 colors highly customized, and build a specific theme for vim/janus. My iterm2 colors are fine, but after the 20161204 nightly build, colors would be all messed up in vim.
I noticed the colors that were off in vim were my iterm2 profile "bright" colors. I tried set background=dark in my .vimrc, but that didn't fix it. However using set background=light, my colors are exactly how I used to have them again!
I clearly did something backwards when configuring vim, but I've fine tuned it the way I like it. I hope this helps for anyone else having an issue with vim colors after December 4th 2016.
syntax enable is useless after syntax on.
set background=dark is also generally useless outside of a colorscheme.
Does your colorscheme work when you do :colorscheme vimbrant? Where did you install it?
After trying all other suggestions made here and elsewhere, the final thing that worked for me was:
set termguicolors

Solarized colorscheme for vim and incorrect background color

I use urxvt with the Solarized light color palette. My .Xresources file is properly configured according to these instructions. I also use Vim as my main editor. I've installed the Solarized colorscheme for Vim and modified my .vimrc file according to these instructions. I like the light background color, so I put the following lines in .vimrc
syntax enable
set background=light
colorscheme solarized
However, Vim set the background color to dark. Then I edited the second line, wrote set background=dark and vim changed the background color to light.
The problem is that set background=light gives me the dark background and set background=dark gives me the light background. Why this weird behavior? How to fix this problem? Ah, if I leave out the set background line, everything looks fine (the background is light). I've also noticed that gvim sets the correct background color.
Well, I found what's going wrong. The official (?) Solarized for X Windows is broken when using light colors. There's a discussion here and here. The color scheme didn't adjust to the value of background. I solved the problem using the config from seletskiy configuration.

vim colorschemes not changing background color

I try to apply various color schemes in vim that I have seen on the net. Whatever scheme I choose, the background remains white, even though screenshots of the applied scheme shows that the background should be colored.
In some schemes, some of the background change color, but space right of lines containing text still remains white.
I'm using Vim 7.2 on a mac. I have just started messing with non-gui applications, so everything should be pretty much as it was out of the box..
Does the overall settings for the terminal window have something to do with it?
When running macvim, everything looks ok. Its only when starting vim from the terminal things looks strange..
I have this in my .vimrc and it solved this problem for me using while using PuTTY.
set t_Co=256
set background=dark
colorscheme mustang
highlight Normal ctermbg=NONE
highlight nonText ctermbg=NONE
It's important to load the colorscheme before the ctermbg settings in .vimrc because they need to override the same ones set by the colorscheme. This also means you can't switch colorscheme while Vim is running and expect it to work.
I'm adding a second answer from me because it's very different from my first answer and may point to actual problem.
If you look at the actual website for the colorscheme here:
Molokai website
you will see a question very similar to yours. Here's answer given, which suggests trying command :set t_Co=256 in your vimrc to see if it fixes things:
"- Make sure you’re using a console terminal capable of 256 colors; not all of them do (particularly on mac). You might need to explicitly force Vim to use that by doing “set t_Co=256″ on your .vimrc file.
- The windows console is well… totally unsupported, that only does 16 colors so it’s a mess"
In linux I had export TERM=xterm-256color in my .bashrc. That caused vim to look like this (after setting set t_Co=256):
When I removed that line from my .bashrc and opened a new terminal (exec bash didn't do it) This is what I get:
Terminals are usually limited to 256 colors while GUI are only limited by color depth of your desktop environment, typically 2^32.
So even if there is lots of vim color scheme available around, implicitly they are often designed for the GUI and won't work for the terminal version.
If you look at color schemes on vim.org, there is often a mention of GUI or 256. So you have to chose which to use depending on the context.
To convert a GUI scheme to terminal you can use the following plugin :
CSApprox.
You can also use a different colorscheme depending on the context, add the following in your .vimrc:
if has("gui_running")
colorscheme [using any color you want]
else
colorscheme [using 256 colors]
endif
I think the problem could be the way the default color is changed by the colorscheme. I've looked at some colorschemes that set default merely by:
set background=light
or
set background=dark
Not sure what limitations of those are. I don't think those work in terminals.
In any case, you should be able to manually set background in a terminal by using the 'Normal' highlight. Insert it into a spot before most of the 'hi' commands in the colorscheme file and it should provide defaults they will work with. For example:
hi Normal ctermbg=White ctermfg=Black guifg=Black guibg=White
Change ctermfg (color terminal foreground) and ctermbg (color terminal background) to be whatever you want (or whatever color you were expecting to see in the colorscheme but now aren't seeing). (Remember, though, if the colorscheme already has a setting for hi Normal then this probably isn't your problem.)
For ctermbg and ctermfg you can enter color names, but I think there is only a fairly limited number:
Black
DarkBlue
DarkGreen
DarkCyan
DarkRed
DarkMagenta
Brown, DarkYellow
LightGray, LightGrey, Gray, Grey
DarkGray, DarkGrey
Blue, LightBlue
Green, LightGreen
Cyan, LightCyan
Red, LightRed
Magenta, LightMagenta
Yellow, LightYellow
White
Otherwise you should be able to use a number from 0 to 255 in place of the color name. Or this script gives rough idea, and lets you see how you could also set up to use more color names:
Vim script with color settings
Also, there are a number of scripts that help you use or convert colorschemes written for gui for use with cterm. E.g.,:
Colorscheme support for cterm
Does the overall settings for the terminal window have something to do with it?
Maybe, but I'm pretty sure a properly written Vim colorscheme will override any terminal settings you've made. At least they do for me in Windows and on Ubuntu. . .
You need to add set termguicolors to your ~/.vimrc
I tested t_Co=256 and other options, but none worked, only set termguicolors
After this you can use the command set bg=light or set bg=dark to see witch one looks better (some vim color schemes accept both options).
Here is a list of terminals that are compatible with termguicolors: https://gist.github.com/XVilka/8346728#now-supporting-true-color
I had the same problem and found out that the answer to this question is actually threefold, where fixing only two of the three isn't enough. You'll need to have:
256-color support in your terminal - Putty with default settings does have this
Vim has to recognize that the terminal is 256-color capable: "set t_Co=256" in your .vimrc will do it
The color scheme needs to have support for color terminals with ctermbg and ctermfg attributes for highlights, not just the gui*-versions. http://www.vim.org/scripts/script.php?script_id=2682 should be able to provide these automatically, and CSApprox I'm using most definitely does, but requires either +gui -compiled Vim or a recent enough Vim version (7.3 or newer).
The third one seems to be the most commonly missed requirement. I wrote a short piece on my own fumblings on this subject just this morning: http://codeandlife.com/2013/09/22/vim-colorschemes-with-putty-aka-gui-vs-xterm-color256/
Final gotcha that happened to me while trying different settings was that when the colors did work, only areas of screen with text had the proper background color. Re-checking Putty Terminal setting "Use background colour to erase screen" fixed that final issue for me.
Does the overall settings for the terminal window have something to do with it?
Yes, terminal parameters override vim parameters (at least in OSX and iTerm). For example, I have a following script in /Users/[username]/.bashrc
setBackground() {
osascript -e "tell application \"iTerm\"
set current_terminal to (current terminal)
tell current_terminal
set current_session to (current session)
tell current_session
set background color to $1
end tell
end tell
end tell"
}
vim() {
(setBackground "{65025,65025,65025}" &)
(exec vim $*)
}
The above remaps terminal vim command to execute a background color change before executing vim. Background color function is applescript (I copied the script from somewhere...). It works for iTerm. I belive that you can adapt this to work with terminal (apple product + apple script -> should work).
br,
Juha
Use this rule if you use Vim through SSH:
Add to your local .bashrc:
export TERM=xterm-256color
Remove from .bashrc any TERM definitions.
If you use same .bashrc on both (local and remote), use temporary environment variable and never set TERM globally:
alias color-ssh='TERM=xterm-256color ssh user#host'
This works for me for switching backgrounds:
colorscheme hemisu
function! g:ToggleBackground()
if &background != 'dark'
set background=dark
else
set background=light
colorscheme hemisu
endif
endfunction
nnoremap <silent> <F3> :call g:ToggleBackground()<CR>
Also try setting light background to something like ctermbg=231, so that tmux handles it better.
I have similar issue that the background color of indentation guides (nathanaelkane's vim-indent-guides) cannot be displayed in my Windows Cygwin's mintty terminal.
I solved the issue with a line Term=xterm-256color in ~/.minttyrc (equivalent to set via mintty's Options GUI: Terminal -> Type -> xterm-256color. This has the effect export TERM=xterm-256color. Without this, mintty default to TERM="xterm", which result in vim's t_Co=8 (instead of t_Co=256) and cannot show some background color.
Checklist:
echo $TERM in bash should give xterm-256color.
in vim, :set t_Co should give t_Co=256.

Resources