5

For some reason when I change my colorscheme it doesn't seem to change all the syntax elements, or changes them to a completely different color than they should be. I know the problem isn't about the color capability of my terminal: when I echo $TERM I get xterm-256color. I've also tried the command set t_Co=256 before changing the colorscheme and it doesn't work.

The color differences seem to be vaguely similar to how they are in this question but I'm running mingw on windows and the comparison is between what I have and an online screenshot of what it's supposed to look like

So far the worst scenario has been with the macvim-light colorscheme: enter image description here

but when I change the colorscheme it looks like this: enter image description here

As you can see there's a huge difference between these two.

As this answer suggests I ran :scriptnames among the files that came up, there seemed to be something possibly relevant in /usr/share/vim/vim80/syntax/syncolor.vim:

if &background == "dark"
  SynColor Comment  term=bold cterm=NONE ctermfg=Cyan ctermbg=NONE gui=NONE guifg=#80a0ff guibg=NONE
  SynColor Constant term=underline cterm=NONE ctermfg=Magenta ctermbg=NONE gui=NONE guifg=#ffa0a0 guibg=NONE
  SynColor Special  term=bold cterm=NONE ctermfg=LightRed ctermbg=NONE gui=NONE guifg=Orange guibg=NONE
  SynColor Identifier   term=underline cterm=bold ctermfg=Cyan ctermbg=NONE gui=NONE guifg=#40ffff guibg=NONE
  SynColor Statement    term=bold cterm=NONE ctermfg=Yellow ctermbg=NONE gui=bold guifg=#ffff60 guibg=NONE
  SynColor PreProc  term=underline cterm=NONE ctermfg=LightBlue ctermbg=NONE gui=NONE guifg=#ff80ff guibg=NONE
  SynColor Type     term=underline cterm=NONE ctermfg=LightGreen ctermbg=NONE gui=bold guifg=#60ff60 guibg=NONE
  SynColor Underlined   term=underline cterm=underline ctermfg=LightBlue gui=underline guifg=#80a0ff
  SynColor Ignore   term=NONE cterm=NONE ctermfg=black ctermbg=NONE gui=NONE guifg=bg guibg=NONE
else
  SynColor Comment  term=bold cterm=NONE ctermfg=DarkBlue ctermbg=NONE gui=NONE guifg=Blue guibg=NONE
  SynColor Constant term=underline cterm=NONE ctermfg=DarkRed ctermbg=NONE gui=NONE guifg=Magenta guibg=NONE
  SynColor Special  term=bold cterm=NONE ctermfg=DarkMagenta ctermbg=NONE gui=NONE guifg=SlateBlue guibg=NONE
  SynColor Identifier   term=underline cterm=NONE ctermfg=DarkCyan ctermbg=NONE gui=NONE guifg=DarkCyan guibg=NONE
  SynColor Statement    term=bold cterm=NONE ctermfg=Brown ctermbg=NONE gui=bold guifg=Brown guibg=NONE
  SynColor PreProc  term=underline cterm=NONE ctermfg=DarkMagenta ctermbg=NONE gui=NONE guifg=Purple guibg=NONE
  SynColor Type     term=underline cterm=NONE ctermfg=DarkGreen ctermbg=NONE gui=bold guifg=SeaGreen guibg=NONE
  SynColor Underlined   term=underline cterm=underline ctermfg=DarkMagenta gui=underline guifg=SlateBlue
  SynColor Ignore   term=NONE cterm=NONE ctermfg=white ctermbg=NONE gui=NONE guifg=bg guibg=NONE
endif
SynColor Error      term=reverse cterm=NONE ctermfg=White ctermbg=Red gui=NONE guifg=White guibg=Red
SynColor Todo       term=standout cterm=NONE ctermfg=Black ctermbg=Yellow gui=NONE guifg=Blue guibg=Yellow

I'm not quite sure if that affects changing the colorscheme though

Anyway here's what I'm using:

Windows 8.1
MSys2
MinGW64
bash 4.3.46
vim 8.0
5
  • 1
    I added a screenshot to my answer that shows what it looks like for me with 'light'. 'dark' looks terrible for me, too. I think this setting is the root cause...beyond that it may just be the poorer quality inherent in terminal Vim.
    – B Layer
    Aug 2, 2017 at 5:25
  • @BLayer, possibly. How can you tell if a .vim script is meant for gVim vs terminal? other than just testing it on each of them? Aug 2, 2017 at 5:28
  • 1
    Author usually indicates but the broader point is that things rarely look as good as they do on GUI.
    – B Layer
    Aug 2, 2017 at 5:31
  • yeah, the code has a lot of gui-this and gui-that and only a light sprinkling of cterm I only have a vague idea of what any of that does, but I wonder if the code for changing color in the terminal is actually buggy and that's why the colors are off. Aug 2, 2017 at 5:48
  • @BLayer you're answer and all your help was indeed very helpful, but didn't completely answer my question which is why I didn't accept it. Aug 2, 2017 at 16:50

2 Answers 2

4

The problem with the specific macvim-light colour scheme you link to is that it has incredibly limited support for terminals: the only syntax groups it adds highlighting for are Normal, DiffAdd, DiffChange, DiffText, and DiffDelete. So if you're not viewing a diff, it essentially does nothing.

In general, screenshots of gVim displaying a colour scheme are unlikely ever to match up well with the output in a 256 colour terminal.

However, if you're are dead set on using colour schemes with poor/no support for terminal colours (most of them), you might want to look into the CSApprox or guicolorscheme plugins or, better, the newish 'termguicolors' option.

1
  • I haven't tried the first two options but the last one worked! Thank you! Aug 2, 2017 at 16:47
3

You may have the "wrong" setting for background. Vim can pick one set of colors for 'dark' and another for 'light'. Some schemes look terrible with one value but great with the other (assuming the scheme isn't optimized for both).

Check your current setting with :set background? and then apply the opposite. For example if the last command returned 'light' then do :set background=dark.

(Note that sometimes I find that "hot-swapping" this value causes the scheme to be altered so it doesn't look right either way. I need to investigate. Choosing the desired setting before opening the file - e.g. by setting it in vimrc file - should work.)

If this was the cause you can find more information here (in addition to Vim help): What does :set background=dark do?

Edit: For reference here's what it looks like from mintty 2.7.9 on my Windows machine with background=light ('dark' looks totally washed out like your example)...

enter image description here

4
  • set background=light solved the problem with the horrendous yellow keywords, but the colors are still off. The keywords are a dark magenta instead of blue, the literals are red instead of orange, I could go on. (I kind of like this colorscheme better actually, but I still don't understand why it's not working the way it should. I'll read up on that link though) Aug 2, 2017 at 4:39
  • though surprisingly, if I just open the editor and change colorschemes the horrendous colorscheme is there but when I set background? it echoes light. but if I set background=light from there, it still sort of fixes it... weird Aug 2, 2017 at 4:50
  • no you're right the first time, I'm using vim. I saw that it was for neovim, but for some reason i thought it wouldn't matter because I found it on vimcolors.com which I assumed was supposed to be specifically for vim, but apparently I'm probably wrong abt that. Aug 2, 2017 at 5:07
  • Nah, looks okay for me. Actually, it looks great with gVim but terminal vim it's so-so. I believe some schemes are really made just for GUI version of Vim and end up looking mediocre in terminal-based Vim.
    – B Layer
    Aug 2, 2017 at 5:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.