Search code examples
macosvimiterm2

vim using iterm2 cannot use colorscheme


So I am trying to get colorscheme support in iterm2 on my mac. When I :colorscheme solarized this is what my screen looks like

enter image description here

Here is my main .vimrc

set nocompatible

let mapleader = ","

set backspace=2
set nobackup
set nowritebackup
set noswapfile
set history=50
set ruler
set showcmd
set incsearch
set laststatus=2
set autoread

set ignorecase
set smartcase

set tabstop=2
set shiftwidth=2
set shiftround

set list listchars=tab:»·,trail:·,nbsp:·

set textwidth=80
set colorcolumn=+1

"set number

set splitbelow
set splitright

set winwidth=84
set winheight=5
set winminheight=5
set winheight=999

set matchpairs+=<:>

" Treat <li> and <p> tags like the block tags they are
let g:html_indent_tags = 'li\|p'

set scrolloff=8
set sidescrolloff=15
set sidescroll=1

"if (&t_Co > 2 || has("gui_running")) && !exists("syntax_on")
"  syntax on
"   set t_Co=256
"   set background=dark
"endif

" Load up all of our plugins
if filereadable(expand("~/.vimrc.bundles"))
  source ~/.vimrc.bundles
endif

filetype plugin indent on

And here is my plugin file

if &compatible
      set nocompatible
    end

    filetype off
    set rtp+=~/.vim/bundle/Vundle.vim/
    call vundle#begin()
Plugin 'gmarik/Vundle.vim'

Plugin 'christoomey/vim-tmux-navigator'
Plugin 'christoomey/vim-tmux-runner.git'
Plugin 'christoomey/vim-run-interactive'
Plugin 'vim-scripts/ctags.vim'
Plugin 'scrooloose/syntastic' "Syntax Highlighting
Plugin 'scrooloose/nerdtree'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'ervandew/supertab'
Plugin 'vim-scripts/tComment'
Plugin 'vim-scripts/HTML-AutoCloseTag'
Plugin 'jiangmiao/auto-pairs'
Plugin 'tpope/vim-fugitive' "Make git awesome
Plugin 'tpope/vim-repeat'
Plugin 'tpope/vim-surround'

Plugin 'Slava/vim-spacebars'
Plugin 'groenewege/vim-less'

Plugin 'altercation/vim-colors-solarized'
Plugin 'bling/vim-airline' "Awesome looking meta at bottom
Plugin 'majutsushi/tagbar'

Plugin 'vim-scripts/matchit.zip'
Plugin 'vimwiki/vimwiki'
Plugin 'mattn/calendar-vim'

    call vundle#end()
    filetype on

    set t_Co=256
    set background=dark
    syntax enable

I have gone into the setting of iterm and set the reporting of the terminal to xterm-256color. I also added to my .zshrc the following lines

export CLICOLOR=1
export TERM=xterm-256color

Solution

  • You need to install the solarized colorscheme to your terminal too.

    From the solarized-vim readme:

    IMPORTANT NOTE FOR TERMINAL USERS:

    If you are going to use Solarized in Terminal mode (i.e. not in a GUI version like gvim or macvim), please please please consider setting your terminal emulator's colorscheme to used the Solarized palette.

    You should download the solarized bundle from here and unzip it.

    Then open iTerm 2, go to iTerm -> Preferences -> Profiles -> Colors. At the bottom it should say Load Presets. Click that and choose import near the bottom. Go to where the downloaded solarized folder is and choose solarized/iterm2-colors-solarized/Solarized Dark (or Solarized Light). Then Solarized Dark (or Light) should be in the drop down menu.

    Then everything should work fine.