Skip to content

How to mitigate highlighting issues when switching colorschemes? #4405

Closed
neovim/neovim
#14060
@lifepillar

Description

@lifepillar

As you know, filetype-specific syntax items and colorscheme's switching don't go very well together—the emblematic discussion of the topic likely being altercation/solarized#102.

In a nutshell, the issue can be reproduced as follows (using Vim 8.1.1300):

  1. Create a minimal colorscheme ~/.vim/colors/test.vim:
set background=dark
hi clear
if exists('syntax_on')
  syntax reset
endif
let g:colors_name = 'test'
hi! link vimCommand ErrorMsg
hi vimOption cterm=reverse gui=reverse
  1. Edit your vimrc;

  2. :colorscheme test

  3. :colorscheme default

You will see that vimCommand is still linked to ErrorMsg and vimOption is cleared.

I have thought hard about possible workarounds and my conclusion is that this issue has no solution—except avoiding using syntax items in colorschemes—unless some new mechanism (a new command?) is introduced in Vim to deal specifically with it. Am I right?

Note that avoiding syntax items in colorschemes is somewhat limiting, as one can realize by looking at two of the most popular colorschemes (Solarized and Gruvbox): people constantly ask to tweak the highlighting for specific filetypes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions