color-scheme reloading (bug?)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

color-scheme reloading (bug?)

Carlos Pita
Hi!

I load a color scheme from my .vimrc and then customize
it by changing the visual block highlighting:

.vimrc
  ...
  color darkscheme
  hi Visual guibg=lightblue guifg=black
  ...

The scheme is tuned for dark background but it doesn't set
the background option by itself. It does clear the previous
highlighting:

darkscheme.vim
  hi clear
  let g:colors_name="darkscheme"
  ....

The problem is that my 'hi Visual...' setting is being overridden
by the default one. According to the 'background' option documentation
when vim detects a dark background at gui startup it will change
background to 'dark' if this option wasn't setted during initialization.
Also when background value is changed the current color scheme will
be reloaded by vim to let it adapt itself to the new setting. Inspired
by that I added a new line to my .vimrc, in order to avoid reloading
of the scheme:

.vimrc
  ...
  set background=dark
  color darkscheme
  hi Visual guibg=lightblue guifg=black
  ...

Now it works. But what if I change dark for light?:

.vimrc
  ...
  set background=light
  color darkscheme
  hi Visual guibg=lightblue guifg=black
  ...

Broken again. The Visual highlight being overriden again.
(presumably by automatic reloading of the scheme by vim,
which causes my customization be discarded by the execution
of 'hi clear'). But I'm explicitly setting the background
(although the setting doesn't match the real background color).

Is this a bug? Am I missing something?

(I'm using vim 6.3)

Thank you in advance.
Regards,
Carlos



       

       
               
___________________________________________________________
1GB gratis, Antivirus y Antispam
Correo Yahoo!, el mejor correo web del mundo
http://correo.yahoo.com.ar 

Reply | Threaded
Open this post in threaded view
|

Re: color-scheme reloading (bug?)

Carlos Pita
I was wrong at one point: even 'set background=dark'
doesn't fix it. The way out is avoiding 'hi clear'
inside the scheme. So evidently it's a problem
of the scheme being (re?)loaded after .vimrc
execution. Is this the expected behaviour? Should
I assume that a color scheme is subject to be
reloaded at any time?

Regards,
Carlos



> Hi!
>
> I load a color scheme from my .vimrc and then customize
> it by changing the visual block highlighting:
>
> .vimrc
>   ...
>   color darkscheme
>   hi Visual guibg=lightblue guifg=black
>   ...
>
> The scheme is tuned for dark background but it doesn't set
> the background option by itself. It does clear the previous
> highlighting:
>
> darkscheme.vim
>   hi clear
>   let g:colors_name="darkscheme"
>   ....
>
> The problem is that my 'hi Visual...' setting is being overridden
> by the default one. According to the 'background' option documentation
> when vim detects a dark background at gui startup it will change
> background to 'dark' if this option wasn't setted during initialization.
> Also when background value is changed the current color scheme will
> be reloaded by vim to let it adapt itself to the new setting. Inspired
> by that I added a new line to my .vimrc, in order to avoid reloading
> of the scheme:
>
> .vimrc
>   ...
>   set background=dark
>   color darkscheme
>   hi Visual guibg=lightblue guifg=black
>   ...
>
> Now it works. But what if I change dark for light?:
>
> .vimrc
>   ...
>   set background=light
>   color darkscheme
>   hi Visual guibg=lightblue guifg=black
>   ...
>
> Broken again. The Visual highlight being overriden again.
> (presumably by automatic reloading of the scheme by vim,
> which causes my customization be discarded by the execution
> of 'hi clear'). But I'm explicitly setting the background
> (although the setting doesn't match the real background color).
>
> Is this a bug? Am I missing something?
>
> (I'm using vim 6.3)
>
> Thank you in advance.
> Regards,
> Carlos
>
>
>
>
>
>
>
> ___________________________________________________________
> 1GB gratis, Antivirus y Antispam
> Correo Yahoo!, el mejor correo web del mundo
> http://correo.yahoo.com.ar 
>
>

       

       
               
___________________________________________________________
1GB gratis, Antivirus y Antispam
Correo Yahoo!, el mejor correo web del mundo
http://correo.yahoo.com.ar 

Reply | Threaded
Open this post in threaded view
|

Re: color-scheme reloading (bug?)

Carlos Pita
Yeah, it's me again. Everything works fine if I do
the set background from .gvimrc instead of from .vimrc.
After more carefully reading the documentation
I find out that it clearly mentions .gvimrc where
I said .vimrc. So -silly me- it has been a fault
of mine (I'm pretty newbie and I wasn't really aware
of the existence of .gvimrc until 5 minutes ago).
"""
When the value is not set in the .gvimrc, and Vim detects
what the background is actually quite dark, 'background' is set to
"dark".
"""
Anyway, isn't this behaviour a little weird? Why
the distinction between setting background at one or
the other initialization file? Is this because settings
at the .vimrc would normally expect a dark console
which could be the wrong assumption for the gui in
many cases?
Regards,
Carlos

> I was wrong at one point: even 'set background=dark'
> doesn't fix it. The way out is avoiding 'hi clear'
> inside the scheme. So evidently it's a problem
> of the scheme being (re?)loaded after .vimrc
> execution. Is this the expected behaviour? Should
> I assume that a color scheme is subject to be
> reloaded at any time?
>
> Regards,
> Carlos
>
>
>
> > Hi!
> >
> > I load a color scheme from my .vimrc and then customize
> > it by changing the visual block highlighting:
> >
> > .vimrc
> >   ...
> >   color darkscheme
> >   hi Visual guibg=lightblue guifg=black
> >   ...
> >
> > The scheme is tuned for dark background but it doesn't set
> > the background option by itself. It does clear the previous
> > highlighting:
> >
> > darkscheme.vim
> >   hi clear
> >   let g:colors_name="darkscheme"
> >   ....
> >
> > The problem is that my 'hi Visual...' setting is being overridden
> > by the default one. According to the 'background' option documentation
> > when vim detects a dark background at gui startup it will change
> > background to 'dark' if this option wasn't setted during initialization.
> > Also when background value is changed the current color scheme will
> > be reloaded by vim to let it adapt itself to the new setting. Inspired
> > by that I added a new line to my .vimrc, in order to avoid reloading
> > of the scheme:
> >
> > .vimrc
> >   ...
> >   set background=dark
> >   color darkscheme
> >   hi Visual guibg=lightblue guifg=black
> >   ...
> >
> > Now it works. But what if I change dark for light?:
> >
> > .vimrc
> >   ...
> >   set background=light
> >   color darkscheme
> >   hi Visual guibg=lightblue guifg=black
> >   ...
> >
> > Broken again. The Visual highlight being overriden again.
> > (presumably by automatic reloading of the scheme by vim,
> > which causes my customization be discarded by the execution
> > of 'hi clear'). But I'm explicitly setting the background
> > (although the setting doesn't match the real background color).
> >
> > Is this a bug? Am I missing something?
> >
> > (I'm using vim 6.3)
> >
> > Thank you in advance.
> > Regards,
> > Carlos
> >
> >
> >
> >
> >
> >
> >
> > ___________________________________________________________
> > 1GB gratis, Antivirus y Antispam
> > Correo Yahoo!, el mejor correo web del mundo
> > http://correo.yahoo.com.ar 
> >
> >
>
>
>
>
>
> ___________________________________________________________
> 1GB gratis, Antivirus y Antispam
> Correo Yahoo!, el mejor correo web del mundo
> http://correo.yahoo.com.ar 
>
>

       

       
               
___________________________________________________________
1GB gratis, Antivirus y Antispam
Correo Yahoo!, el mejor correo web del mundo
http://correo.yahoo.com.ar 

Reply | Threaded
Open this post in threaded view
|

Re: color-scheme reloading (bug?)

A.J.Mechelynck
Carlos Pita wrote:

> Yeah, it's me again. Everything works fine if I do
> the set background from .gvimrc instead of from .vimrc.
> After more carefully reading the documentation
> I find out that it clearly mentions .gvimrc where
> I said .vimrc. So -silly me- it has been a fault
> of mine (I'm pretty newbie and I wasn't really aware
> of the existence of .gvimrc until 5 minutes ago).
> """
> When the value is not set in the .gvimrc, and Vim detects
> what the background is actually quite dark, 'background' is set to
> "dark".
> """
> Anyway, isn't this behaviour a little weird? Why
> the distinction between setting background at one or
> the other initialization file? Is this because settings
> at the .vimrc would normally expect a dark console
> which could be the wrong assumption for the gui in
> many cases?
> Regards,
> Carlos

When starting gvim, the GUI (the Vim screen) opens only after the gvimrc
has been processed, unless there is an explicit "gui" statement to make
it start earlier. Whether the default background is actually light or
dark can only be found out after opening the GUI, thus the 'bg' setting
is unstable until then.

See also my other post, about how standard colorschemes do it,
explicitly setting 'bg', either with

hi clear Normal
set bg&
hi clear

or with something on the lines of

set bg=dark
hi clear
...
hi Normal ...


Best regards,
Tony.