vimterminalansi-colors

How to use normal colors in vim on MacOS terminal


I have an issue with vim on MacOS terminal. This is a screenshot of my terminal colour palette:

enter image description here

and here is an example of a file open in vim

enter image description here

My .vimrc is the following:

syntax on
set noswapfile
set tabstop=2
set shiftwidth=2
set expandtab
set autoindent
set fileformat=unix
set number 
set relativenumber
set noerrorbells
set encoding=utf-8
set wildmenu
set smartcase
set ruler 
set incsearch
set ignorecase smartcase 
set path+=**

call plug#begin('~/.vim/plugged')
Plug 'jiangmiao/auto-pairs'
"Plug 'bling/vim-airline'
"Plug 'vim-airline/vim-airline-themes'
"Plug 'airblade/vim-gitgutter'
call plug#end()

As you can see, no color setting is present, so it seems that vim uses bright colours by default. Do you know how to make it use normal colours?


Solution

  • The theory.

    When Vim starts, it checks if your terminal emulator window's background is "dark" or "light".

    If it is "dark", Vim sets the :help 'background' option to dark and loads a default colorscheme that makes use of "bright" colours because they work better on a "dark" background.

    If it is "light", Vim sets the 'background' option to light and loads a default colorscheme that makes use of "normal" colours because they work better on a "light" background.

    The reality

    Knowing if a terminal emulator window's background is "dark" or "light" in a dependable cross-platform way happens to be a hard problem and Vim's simplistic approach is as bad as it gets: in Terminal.app, 'background' is set to light no matter what window background you have (it has other issues in other environments).

    In theory, the issue above shouldn't hurt you too much because you want "normal" colours and that's what you should theoretically get with 'background' set to light. But the default colorscheme is not really consistent in its choice of colours, it effectively uses a mix of "bright" and "normal" colours in both cases.

    What to do?

    Basically, you won't be able to solve your problem with default Vim stuff.