After upgrading to neovim 0.10, some autocommands such as autocmd ColorScheme * hi Normal ctermbg=none
have stopped working in terminal. For me this happens in windows subsystem for linux through windows terminal. The reason and workaround is documented below as an answer.
TL;DR
- Option 1: Add
gui
everywhere wherecterm
is used. - Option 2: Add
set notermguicolors
in init.vim
Explanation
Neovim 0.10 has this breaking change (source: https://neovim.io/doc/user/news-0.10.html):
‘termguicolors’ is enabled by default when Nvim is able to determine that the host terminal emulator supports 24-bit color.
When termguicolors
is enabled, the gui
commands become relevant instead of cterm
. From this stackoverflow answer (what is the difference between cterm color and gui color?):
ctermxx
is used by console version of Vim (whenset notermguicolors
).guixx
is used in GVim, or in console ifset termguicolors
, and the console is capable of TrueColor, obviously.
Thus, an autocommand like autocmd ColorScheme * hi Normal ctermbg=none
should change to autocmd ColorScheme * hi Normal guifg=none
, since now the gui
part is relevant even in a terminal. Of course, one could always use both gui
and cterm
in the autocommands to be safe: autocmd ColorScheme * hi Normal guifg=none ctermbg=none
.
Obviously, the other option is to turn off termguicolors
through set notermguicolors