2

I've been fiddling with neovim color schemes for a while now, and cannot make them look same as on previews.

I'm using terminal.app on osx, and thought it was 256 color cap problem, so I moved to iterm2 which has true color support - while it improved some things, color schemes are nowhere near to screenshots I see!

enter image description here

this is how solarized theme looks in iterm2 + neovim

enter image description here

this is nothing close to https://github.com/altercation/vim-colors-solarized screenshots!

I've used google foo but without success, surely there is a way to get colors right. Any ideas?

  "*****************************************************************************
"" Plug install packages
"*****************************************************************************

" Specify a directory for plugins
call plug#begin('~/.config/nvim/plugged')

Plug 'tomasr/molokai'
Plug 'dracula/vim'
Plug 'justb3a/vim-smarties'
Plug 'tyrannicaltoucan/vim-quantum' " let g:quantum_black = 1
Plug 'mhartington/oceanic-next'
Plug 'altercation/vim-colors-solarized'
" Plug 'vim-scripts/CSApprox'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'scrooloose/nerdtree'
Plug 'airblade/vim-gitgutter'
Plug 'bronson/vim-trailing-whitespace'
Plug 'editorconfig/editorconfig-vim'
Plug 'Raimondi/delimitMate'
Plug 'scrooloose/syntastic'
Plug 'Yggdroot/indentLine'
Plug 'tpope/vim-commentary'
Plug 'sheerun/vim-polyglot'
Plug 'valloric/matchtagalways'

" Initialize plugin system
call plug#end()

"*****************************************************************************
"" Visual Settings
"*****************************************************************************
set number
set ruler
set nowrap

let $NVIM_TUI_ENABLE_TRUE_COLOR=1 
set termguicolors " unfortunately doesn't work in terminal.app - needs true color support, like iterm2 but it lags and diff in visuals is not that much so sticking to terminal.app for now

set background=dark
colorscheme solarized

"*****************************************************************************
"" NERDTree config
"*****************************************************************************

" open NERDTree automatically when vim starts up on opening a directory
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif

" keep focus on NERDTree when opening a directory
autocmd VimEnter * wincmd p

" close vim if the only window left open is a NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif

"*****************************************************************************
"" Optimizations
"*****************************************************************************

set lazyredraw

let g:python_host_skip_check = 1
let g:python3_host_skip_check = 1

"*****************************************************************************
"" syntastic
"*****************************************************************************

let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0

"*****************************************************************************
"" yank and cut to osx clipboard
"*****************************************************************************

noremap YY "+y<CR>
noremap XX "+x<CR>

"*****************************************************************************
"" indent
"*****************************************************************************

" tabs
set listchars=tab:˗\ ,eol:¬
set list

" spaces
let g:indentLine_enabled = 1
let g:indentLine_concealcursor = 0
let g:indentLine_char = '·'
let g:indentLine_faster = 1

set tabstop=2

"*****************************************************************************
"" matchtagalways
"*****************************************************************************

let g:mta_filetypes = { 'html' : 1, 'xhtml' : 1, 'xml' : 1, 'jinja' : 1, 'php': 1 }

"*****************************************************************************
"" ctrlp
"*****************************************************************************

set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__
let g:ctrlp_custom_ignore = '\v[\/](node_modules|target|dist)|(\.(swp|tox|ico|git|hg|svn))$'
4
  • Try let g:solarized_termcolors=256 in your config file.
    – anaotha
    Jan 11, 2017 at 19:58
  • @vatsug tried, doesn't help. btw, this happens with every color I find on vimcolors.com it seems like a big issue.
    – user66044
    Jan 11, 2017 at 20:05
  • What happens when you do a like-for-like comparison using the same programming language?
    – JdeBP
    Jan 11, 2017 at 20:58
  • @JdeBP colors are way off without any logic to it. I managed to get solarized working properly in vim by setting terminal profile to slarized color scheme. But this is not possible for other colors only solarized.
    – user66044
    Jan 11, 2017 at 21:14

1 Answer 1

3

Every color scheme defines terminal colors separately from GUI colors. Traditionally, terminals supported at most 256 colors, and they mostly use a palette of 16 colors. GUIs commonly support 24-bit colors, so Vim (and Neovim) provide separate highlighting settings for color scheme authors.

Nowadays, many modern terminals support 24-bit colors as well. However, even when running in such a terminal, Neovim normally uses the terminal colors scheme and the 256-color rendering methods. This setting

set termguicolors

causes Neovim to render 24-bit colors, using the GUI color scheme settings. However, this does not cause Neovim to pretend that it is actually running in a GUI—that is, has('gui_running') is correctly still false.

Unfortunately, due to the historic conflation of GUI mode with 24-bit color mode, you may find that some addons do not handle termguicolors correctly. Your situation is such a scenario. The current implementation of vim-solarized-colors uses has('gui_running') to set the correct colors for 24-bit color mode, so it ends up setting an odd mish-mash of wrong values when Neovim uses 24-bit colors but is not running in a GUI.

Fortunately, the fix is quite simple: patch vim-solarized-colors to abide by &termguicolors where appropriate. You can find the patch in this commit on my fork of the addon. Incidentally, that fork contains some other patches that you may find useful. Feel free to point to it in your Vim config or apply the patches to your own version as you like.

You must log in to answer this question.