color issue with VIM and iTerm2 - colors

I have a color issue on iTerm 2 (both stable and beta release) using VIM (last version).
This is a screenshot on iTerm 2 using vim-css-color plugin :
And the same on the Terminal.app :
As you can see, iTerm renders quite strange colors (and not only with this plugin, this is just an example). I've been playing with the contrast slider in iTerm2 prefererences and every Vim parameter i found so far (x-term-color-256, etc etc).
This is my .vimrc file : https://github.com/nanark/.vim/blob/master/vimrc
Any idea ?

A terminal with 256 color support (like iTerm 2) is simply not capable of displaying the full range of colors.
The css plugin uses a conversion to approximate the hex color code in the terminal. This was designed to work with the default set of colors used by xterm based on the comments in the code.
If you want an accurate preview, you should use gvim or macvim.

Related

Solarized colors inside terminal emacs

I trying to setup the solarized color scheme for Emacs running in terminal mode. I use
https://github.com/bbatsov/solarized-emacs.git 's solarized-dark theme. However while this works for desktop windows the colors are modified when running in terminal mode emacs -nw:
The color is a dark blue while the standard background for solarized dark
is dark and geenish:
The standard background color #002b36 is defined here. I tried to change it but there seem to be an interpolation layer inside Emacs that changes it to blue unless I change it to something more different like black.
Does anyone know howto configure Emacs to support more color shades?
I'm running inside Kconsole but can see the same behaviour in gnome-terminal.
By default terminal works in 16 colors mode. You have to set environment variable TERM:
export TERM=xterm-256color
I'm using zsh, so I put this line in my ~/.zshrc file.
https://github.com/sellout/emacs-color-theme-solarized handles solarized dark theme colors in terminal mode.

Vim using wrong colors

I have a problem with my vim and terminal configurations.
I am on Fedora Linux 27, run i3 and the gnome-terminal. I want to use the srcery color scheme (GH page). On GVim it works perfectly, right out the box. However, on the terminal it doesn't look as good. Srcery isn't the only color scheme with this issue, virtually all Base16 color schemes and all others that use 256 colors suffer from the same problem.
What I find bizarre, is that my $TERM variable is set to xterm-256color, tput colors gives out 256, and even vim itself claims to have a t_Co set to 256. I can do things like make the background of vim transparent, which then works properly.
you can see the color scheme working properly in GVim
a comparison to normal vim.
I have my gnome-terminal colors set to the srcery colors as well, there's a script on the GH page to create a srcery profile, which i am using. Alas, that does not help with my issue either.
Currently, I don't know how i could enable vim to correctly display my color scheme
Any help you could provide would be greatly, greatly appreciated.

Why MacVim does not display some fonts properly?

OS: Mac OS X 10.10.3
MacVim: 7.4.712
I am trying to use MacVim to write LaTeX instead of Sublime Text.
So I set the font "Lucida Grande" from menu of MacVim but it looked strange:
This is what Lucida Grande looks like in Sublime Text:
Then I set "Helvetica" in MacVim and it looks like:
It seems that MacVim tries to display fonts in mono but this is not what I want. How could I set the font properly in MacVim just like what Sublime Text does?
While GVIM / MacVim can use proportional fonts (on certain platforms), there's no way around the screen-cell based addressing in Vim; it's a fundamental concept (taken from the terminal), and many features (like blockwise selections) depend on it.
So, you have to live with the fact that an i will take as much horizontal space as a W, and choose a corresponding (monospaced) font accordingly. This way, your editor will look much better :-)

Use arbitrary colors in Vim and terminator

I am working on terminal Vim colorscheme (for 256-color terminal) and I need a few dark colours that I could use as backgrounds. I'm not satisfied with ones available in standard palette - for example, color 22 (#005f00), the darkest shade of green, is still too bright.
I've read that terminal Vim does not allow specifying colors as RGB, so - to get arbitrary colors - I would have to tweak terminal emulator's color palette. Is there a way to tweak full 256-color palette in gnome-terminal / terminator? Preferences window only allows editing basic 16.
BTW, Chrome's hterm allows this via 'color-palette-overrides' preference (but has its own drawbacks).
Gnome-terminal doesn't offer a UI to alter the colors (apart from the first 16), but you can use escape sequences, e.g.:
echo -ne '\e]4;22;#004f00\a'
As you've mentioned, sometimes these colors get reset to their default values. This was a bug in the underlying VTE library, and got fixed in version 0.36.
As far as I know, you won't find a single terminal emulator that gives you that kind of control over the whole standardized xterm palette.
So, if you ever intend to share that colorscheme you are stuck with the default palette.
On the other hand, if that colorscheme is only meant for your usage or if you are OK with forcing a hard dependency on your users, you can use japh's colorcoke to generate an alternate palette more suited to your needs. See the repo's wiki for examples)

Solarized color scheme and palette distorts for ssh'd users in iTerm2

My setup includes vim, iTerm2, tmux, and the solarized dark color scheme. I have the dark solarized color palette loaded into iTerm2 (modifies the ansi colors) and do not use the degraded solarized color scheme (i.e., let g:solarized_termcolors=256) as talked about in the readme as an alternative to using the color palette. Everything looks great.
But, I often remote pair with co-workers. Folks ssh into my machine from other instances of iTerm2 and sometimes Terminal.app and create a new tmux session with my tmux session as their base/parent session. In the case of iTerm2, their setup does not include loading the solarized color palette (one uses another palette entirely) and setting the let g:solarized_termcolors=256 to use the degraded solarized color scheme. If that's what they want, great, but when they connect to me via ssh/tmux the colors are lost and often times distorted to the point of being illegible.
Is there any combination of settings, besides having everyone use the same settings, to remedy this? Right now the recommendation is for me to use the degraded color scheme and not load the solarized color palette so that the ansi colors are not modified. This does work, but leaves me w/ the degraded solarized color scheme. And as I prefer the non-degraded solarized color scheme, I'd prefer not to take this approach.
When used in a terminal, the solarized colorscheme for Vim defaults to 16 colors and depends on the palette of the terminal emulator because it uses "Red", "Yellow"… as values for ctermfg and friends.
If you want the same colors everywhere you obviously need to have the same palette everywhere because your "Red" may not be someone else's "Red".
I don't know what the author smoked when he wrote it but let g:solarized_termcolors=256 is not "degraded" at all compared to the default. The default uses only a palette of 16 colors (dependant on the terminal's palette, as we have already seen) while this option makes it use a terminal-independant 256 colors palette. Because the colorscheme is not dependant on the terminal emulator's palette anymore, the colors are actually "guaranteed" to look "good" and "the same" on your terminal emulator and on someone else's terminal emulator.
The catch is that your terminal emulator and their terminal emulators must support 256 colors. All of todays terminals do, but the default is often set to 16 colors. It's generally easy to turn 256 colors support "on", though.
But this option is Vim-only. The colors of your prompt or of the output of some commands or of tmux's TUI may still feel "off" to your co-workers.
The ability to customize the hell out of your setup is of course an important aspect of the Vim experience. But customization comes at a price. You get used to many little things and it could happen that, confronted to a vastly different setup, well… you just get lost. Or, as happens to you, your setup is customized to the point of being unusable by your co-workers.
Pair programming can only work if you and your pair are able to reach compromise on a setup. Obviously, this setup may not be exactly yours or his but you must find a middle ground on which everyone agrees for pairing to work. Because you and your pair may use different versions of tmux/vim, different shells or different terminal emulators, the safest bet is to use the most basic setup possible. Unfortunately for you, solarized is too fragile and far from being "basic" enough.

Resources