Terminal color scheme gets overriden when adding .vimrc file

Working on a fresh install of the i3 community edition. By default, there is no .vimrc file.

I’ve installed a branch of st (see here: GitHub - siduck/st: snazzy terminal (suckless + beautiful)) which works as expected and has a nice color scheme. However, when adding a blank .vimrc file I lose the st color scheme and am stuck with colorless text. Is there some kind of default “no color” scheme for vim so that the st settings are not overridden? Alternatively, can I somehow copy the st scheme verbatim over to vim? Note that I’d rather avoid having an altogether different scheme set within the .vimrc itself.

Am struggling with this as I’m not sure what st itself is doing to interpret text within the terminal independently of the program running and why adding a vim config file (without any mention of colors) changes anything. For instance, without a .vimrc file nvim and vim have a slightly different color scheme each.

You’re probably using Vim in 256-color mode. From Vim’s normal mode, try the command :se t_Co. It will return t_Co=256 if I’m correct. You can limit Vim to use just the sixteen colors set by st’s xresources file with :se t_Co=16. If it works for you, add it to your .vimrc.

You may find you want to write your own or edit someone else’s colorscheme to use just st’s 16 colors.

Thanks for this. You are right, :se t_Co returns t_Co=256. However adding set t_Co=16 to my .vimrc doesn’t seem to help.

I’ve just noticed that nvim doesn’t seem to have any of these issues (there are no t_xx opts after all). I might just make the switch.

Finally, I did install gvim at some point in order to get clipboard access - not sure if that factors into anything.

Thanks anyway!

You can try :set termguicolors (:se tgc). Turn it off with :se notgc. See :h tgc. With tgc on, setting :hi Normal guibg=NONE and :hi Normal guifg=NONE may then help.

What colorscheme are you using in vim?

The Archwiki says the equivalent of Vim’s ~/.vimrc for Neovim is ~/.config/nvim/init.vim. I’ve never used nvim.

If you do go with writing your own colorscheme, I think you want to limit the colors to those shown with :h cterm-colors.

Thanks. Yes

What colorscheme are you using in vim?

None, preferably. I noticed that st applies its own color scheme to all text in my terminal including files of different extensions etc and figured i’d rather just stick with that than have to fiddle around with vim too.

Will keep this in mind.