Vim using wrong colors - vim

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.

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.

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.

color issue with VIM and iTerm2

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.

Why doesn't VIM recognize a color totally available?

This is mystery drives me crazy: I am trying to specify certain colors that are listed inside gVim 7.3 when running this script.
But when put in a .vim syntax file, gVim simply issues an error "Color name not recognized". This happens even with simple colors like orange. Instead, it only recognizes a few colors like red, blue, yellow, darkyellow, darkgreen, black, etc.
Why does this happen and how to workaround this?
Because, as a terminal program vim only supports ANSI colors by default.
http://en.wikipedia.org/wiki/ANSI_escape_code#Colors
I don't know enough about syntax files to fully answer, but these links might be useful
http://vim.wikia.com/wiki/256_colors_in_vim
http://vim.wikia.com/wiki/View_all_colors_available_to_gvim
It's possible that only the normal colors are available to syntax files from there you can use a different color scheme to reassign the normal colors.
http://vimcasts.org/episodes/creating-colorschemes-for-vim/
I ended up solving the problem by hard coding the offending color (orange) in the .vim file:
hi def MyOrange_color ctermfg=202 guifg=#ff5f00

Resources