Sunday, August 12, 2018

Set background and hi Normal: in which order?

Dear masters of Vim colorschemes,
which of the following should a dark-only colorscheme use?

(1)
set background=dark
hi Normal ...
" Other highlight groups here

(2)

hi Normal ...
set background=dark
" Other highlight groups here

(3)
hi Normal ...
" Don't set 'background' at all.
" Other highlight groups here

I am asking because I have always used (1), but recently I have found
an instance (iVim for iOS, which is based on Vim 7.4.900) in which my
colorscheme has the wrong color for the status line. The relevant part
of the highlight group is defined as follows (below you find the full
definition):

hi StatusLine guifg=#64878f guibg=fg gui=NONE,reverse

At startup, the foreground color of the status line is set to Normal
background (#292c36) instead of Normal foreground (#ffffff). Reloading
the colorscheme is necessary to get the right color.

Either setting the background *after* defining the Normal hi group or
relying on Vim to set the background correctly fixes the issue. So,
now I am leaning towards using (2) as a more robust choice, but you
know better.

So, what is the "best practice" here: (1), (2), or (3)?

Thanks,
Life.


Full example:

set background=dark

hi clear
if exists('syntax_on')
syntax reset
endif

let g:colors_name = 'test'

hi Normal ctermfg=15 ctermbg=0 guifg=#ffffff guibg=#292c36
\ guisp=NONE cterm=NONE gui=NONE
hi StatusLine ctermfg=6 ctermbg=15 guifg=#64878f guibg=fg
\ guisp=NONE cterm=NONE,reverse gui=NONE,reverse



--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: