overcache / NeoSolarized

NeoSolarized: A fixed solarized colorscheme for better truecolor support.
MIT License
517 stars 99 forks source link

Affecting other colorschemes #7

Closed ghost closed 7 years ago

ghost commented 7 years ago

I am using NVIM v0.2.0-45-g7666b49 inside tmux 2.3 in gnome-terminal on Debian Jessie, all of which are properly setup to display true color. I am using three 24 bit colorschemes and want to be able to switch between them:

However, as soon as I use the NeoSolarized colorscheme once - whether I set it in my init.vim or via :colorscheme NeoSolarized makes no difference - the other two colorschemes no longer look as they did before when I reactivate them with :colo tender or :colo onedark. Some words that used to be highlighted with color before are no longer highlighted with a color. This happens only when I use the NeoSolarized colorscheme - between the other two I can switch without any problems.

Steps to reproduce:

  1. Create this init.vim and download the three truecolor colorschemes with vim-plug:
    call plug#begin()
    " three 24bit/truecolor colorschemes used for this example
    Plug 'jacoborus/tender'
    Plug 'joshdick/onedark.vim'
    Plug 'iCyMind/NeoSolarized'
    call plug#end()
    set termguicolors
    set background=dark
    colorscheme tender
  2. Open init.vim in nvim. Notice that the words call, set and colorscheme in init.vim are all colored. (2.1 Run :colo onedark. They are still all colored.) (2.2 Run :colo tender. Still colored.)
  3. Run :colo NeoSolarized. They are still colored.
  4. Run either :colo tender or :colo onedark. The words call, set and colorscheme in init.vim are no longer colored.

Alternative way to reproduce: Take the init.vim given above an replace the last line (colorscheme tender) with colorscheme NeoSolarized. Run :colo tender or :colo onedark. The words call, set and colorscheme in init.vim are no longer colored.

overcache commented 7 years ago

Hi, cbaumhardt, thanks for help.

Check for more infomation about this bug at https://github.com/altercation/solarized/issues/102

If you change your colorscheme frequently, the vim-colorscheme-switcher plugin is highly recommended to avoid this issue.

ghost commented 7 years ago

Thanks for your quick answer. The interesting thing to me is that this bug seems to just happen with the solarized/NeoSolarized colorscheme. The problem does not happen if I use other true color schemes like tender or onedark. I wonder if this issue could simple be fixed by changing colors/NeoSolarized.vim to be more like colors/tender.vim. It seems logical to me that this would fix the issue.

overcache commented 7 years ago

Words like set and colorscheme in init.vim are identify as 'vimCommand' by $NVIMRUNTIME/syntax/vim.vim.

And words in group 'vimCommand' are highlighted same color as 'Statement' by hi def link vimCommand Statement.

Solarized specify a color(yellow) for the 'vimCommand' group, so their color are different with 'Statement' group.

Onedark or tender doesn't specify color for 'vimCommand' group, words in 'vimCommand' highlight group will render as nohighlight when you switch from solarized/NeoSolarized to onedark/tender/other-colorscheme.

As tpope said at https://github.com/altercation/solarized/issues/102

From syntax/vim.vim: hi def link vimCommand Statement That means "unless vimCommand is already defined, link it to Statement" (see :help :hi-default). Solarized declares it to be yellow. When you switch away from Solarized, Vim resets all the highlighting. But when syntax/vim.vim is reapplied, vimCommand is already "tainted", so the highlight default no longer applies. Ergo, it's left cleared. At least, that's my best understanding of it. Clearly it's an incomplete explanation as other groups appear fine.

Yes, this issue can fixed simply, just delete lines in vim syntax highlighting section in colors/NeoSolarized file. But it will lose color and I won't do that.

ghost commented 7 years ago

Thanks for clarification, I misunderstood something the first time I read the linked post. I am now using xolox/vim-colorscheme-switcher as you suggested and no longer experience any problems with NeoSolarized.