Follow up to this question - I've narrowed the issue down to the fact that set t_Co=16
in ~/.vimrc
is not being applied.
SO post on restricting vim to 16 colors.
If I open vim and execute :echo &t_Co
, value is set to 256
. If I then manually execute :source ~/.vimrc
, then :echo &t_Co
again, I see the desired value of 16
.
I've removed every plugin in my config to see if that was causing the issue but it persists anyway. Below are relevant .vimrc
settings - this is the very end of the file:
set notermguicolors
set t_Co=16
syntax on
highlight clear CursorLine
highlight clear Todo
highlight signcolumn ctermbg=8
highlight statuslinenc ctermbg=3 ctermfg=8
highlight matchparen ctermbg=1 ctermfg=7
highlight diffchange ctermbg=0
highlight difftext ctermfg=8
I don't see any references to t_Co
when inspecting via vim -V
either. FWIW this issue started happening only after a recent iTerm2 and MacOS update. I've tried putting t_Co
before syntax on
, after it, before notermguicolors
, after it, at the beginning of the file, at the end of the file. I presume something is happening during startup outside of .vimrc
that does not happen again when I manually :source ~/.vimrc
, but not sure where to look next.
I could set iTerm2 to an ansi terminal to limit colors that way but that was messing up other stuff. I would like t_Co
to dictate available colors in vim, and to be applied on startup.
Setting t_Co to 256 while leaving term to its Vim-defined value — or, more generally, setting t_Co and/or term to values that don't match with the host terminal — makes no sense and will likely create troubles when Vim sends a signal that is not understood by the terminal or vice-versa.
Thanks!