2

I'm having a trouble with Neovim colors when using my vimrc file as Neovim's init.vim.

Here's the expected look, how it looks in Vim:

correct look

And here is how it looks in Neovim:

wrong look

I guess that's because of the :set background? shows:

background=dark

although it's obviously light and it's set as set background=light in the init.vim file.

2 Answers 2

2

The background setting actually doesn't control the background colors but more the foregrounds colors. It dates from a time (that includes the present for some terminal) where the background couldn't be controlled.

It is a way to tell the colorscheme or Vim in general what kind of color should be selected to offer a good contrast with the background (i.e. select light foreground color if the background is dark, select dark foreground color if the background is `light).

Remark: about the reason for which the sequence of the background option setting and the colorscheme settings is important is the following line of the default colorscheme:

set bg&

It resets the background option to its default which is dark.

2

The reason was that the order of options in the init.vim file is important.

Originally it was:

set background=light
colorscheme default

I changed it to

colorscheme default
set background=light

And it started to look correctly. Don't know if that's specified in the docs.

4
  • 1
    The $VIMRUNTIME/colors/default.vim as a set bg& that reset the background option to its default (which is dark). Mar 8 at 10:11
  • @VivianDeSmedt anyway it's strange that despite the color scheme sets it's to dark it remains light in practice. Not sure if it's documented or more like a bug
    – d.k
    Mar 8 at 10:34
  • 1
    It is a feature :-) It dates from the time Vim couldn't control the background of the terminal. The setting only controls the foreground colors based on the indication of the terminal background (dark or light). Mar 8 at 12:42
  • 1
    @VivianDeSmedt thank you, that actually qualifies for the answer to the question, would you mind post it?
    – d.k
    Mar 8 at 14:34

Your Answer

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

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