-1

I would like to apologize in advance that I am asking another Vim/iTerm2 colorscheme question. I looked through StackOverflow and other online resources, but none of the solutions solved/answered my question.

Basically, I am trying to setup the Solarized Light scheme in iTerm2 (for usage in terminal vim too).

The terminal being used in my iTerm2 is xterm-256color.

I am trying to mimic this colorscheme (found in this YouTube video): enter image description here

That YouTube video links this page which describes how to get the colorscheme seen in the video:

The tutorial above basically gives instructions on how to download the Solarized Light color scheme and the Solarized dir colors for wsltty.

In my iTerm2, I selected the Solarized Light preset color scheme (Preferences -> Profiles -> Colors -> Color Presets -> Solarized Light). Then, for the Solarized Light colorscheme in Vim, I downloaded the Solarized Light colorscheme (from here) and set my .vimrc to use this colorscheme.

For context, here is my vimrc:

source $VIMRUNTIME/vimrc_example.vim
 
set hls
set is
set cb=unnamed
set gfn=Fixedsys:h10
set ts=4
set sw=4
set si
set termguicolors
"colorscheme blandon
syntax on
colorscheme solarized
set background=light

highlight Cursor guifg=black guibg=black

inoremap { {}<Left>
inoremap {<CR> {<CR>}<Esc>O
inoremap {{ {
inoremap {} {}
 

and here is the vimrc from the colorscheme I am trying to mimic:

"General editor settings
set tabstop=4
set nocompatible
set shiftwidth=4
set expandtab
set autoindent
set smartindent
set ruler
set showcmd
set incsearch
set shellslash
set number
set relativenumber
set cino+=L0 
syntax on
filetype indent on
filetype off
setlocal indentkeys-=:

"Theme (requires Solarized Light terminal theme to work properly)
let g:solarized_termcolors=256
set background=light
colorscheme solarized

"keybindings for { completion, "jk" for escape, ctrl-a to select all
inoremap {<CR>  {<CR>}<Esc>O
inoremap {}     {}
imap jk         <Esc>
map <C-a> <esc>ggVG<CR>
set belloff=all

As you can see, the colorscheme looks considerably different from the one I am trying to mimic. Anyone have any ideas why this could be happening?

Update (new photos after making changes from answer): enter image description here

Solved: The issue was that the vimrc in the YouTube video contains a special plugin to enhance cpp highlighting. Including this plugin in my vimrc fixed the issue.

Rahul
  • 181
  • 1
  • 2
  • 13

1 Answers1

1

First, the terminal reporting xterm-256color is necessary but insufficient, you also need to instruct vim to use a 256 color palette. Add this to your vim config:

set t_Co=256

Second, there's no guarantee that the colors specified in iTerm's default Solarized Light theme exactly match those as specified in the vim color theme. That will result in slight differences between what you see in example screenshots and what you see in your terminal.

If you want to guarantee a match, check out the base16 project, which has both vim and iTerm 2 outputs. (It also provides lots of other attractive themes, if Solarized isn't exactly your jam.)

In iTerm, import the theme from base16-iterm2:

  • Open Preferences > Profiles,
  • Select your desired profile from the list on the left,
  • Under the "Colors" tab, click on "Color Presets…,"
  • Select "Import…" and then choose the downloaded theme,
  • (Easy to miss) Explicitly select the imported theme in "Color Presets…," which should now be available in the list.

In vim, you'll need to add the color scheme through whatever mechanism you're currently using.

  • Thank you for the response. I have performed all of the steps you have listed and have posted updated photos with what I see. The colorscheme in the photos seems to be completely different from solarized light even tho I specified the base16 solarized light iterm2 file and the base16 solarized light vim file. – Rahul Jul 21 '22 at 21:29
  • Second Update: The reason my second photo had the dark background is because there was a bug with the base16 solarized light theme. I fixed it by adding let g:airline_theme = 'base16' to my vimrc. The colors now match the solarized light theme, but they don't match the colors in the first screenshot of my post. The creator of that YT video said that they were using the solarized light theme for vim too. I'm not sure why their text colors look more colorful than mine. For example, "cout" is cyan with their vim colorscheme but grey in mine even though both colorschemes are solarized light. – Rahul Jul 22 '22 at 05:37
  • No. `xterm-256color` is enough. – romainl Jul 22 '22 at 08:26