rakr / vim-one

Adaptation of one-light and one-dark colorschemes for Vim
MIT License
1.99k stars 196 forks source link

Undefined variable error in iTerm2 #77

Closed jonsmithers closed 6 years ago

jonsmithers commented 6 years ago

I'm getting this error when switching to the colorscheme:

Error detected while processing /Users/smithers/.vim/plugged/vim-one/colors/one.vim:
line  840:
E121: Undefined variable: s:dark
E15: Invalid expression: s:dark
Press ENTER or type command to continue

Here is a minimal vimrc I've been using to test this:

set runtimepath^=~/.vim/plugged/vim-one/
syntax enable        " error occurs with or without this
set termguicolors    " error occurs with or without this
set background=light " error occurs with or without this
colorscheme one

It doesn't happen in Terminal, only iTerm. I tried creating a brand new iTerm profile so everything was default but the error persists.

jonsmithers commented 6 years ago

s:dark only gets declared if one of these conditions is met:

if has('gui_running') || &t_Co == 88 || &t_Co == 256

For me, &t_Co is 8 (only in iTerm). And I'm running inside a terminal.

jonsmithers commented 6 years ago

Adding set t_Co=256 in the minimal vimrc gets it to work.

This is traditionally how I get all my colors:

     if (has('termguicolors'))
       set termguicolors
     else
       set t_Co=256
     endif

Maybe that's the wrong way of doing it. Maybe I should be doing this:

     set t_Co=256
     if (has('termguicolors'))
       set termguicolors
     endif

(EDIT) maybe not? I think termguicolors alone should get you true color, as if has('gui_running') were true.

sseale-zz commented 6 years ago

I get this with Mac Terminal as well

colorscheme one let g:one_allow_italics = 1 set background=dark

Error detected while processing /Users/{user}/.vim/plugged/vim-one/colors/one.vim: line 840: E121: Undefined variable: s:dark E15: Invalid expression: s:dark E121: Undefined variable: s:dark E15: Invalid expression: s:dark E121: Undefined variable: s:dark E15: Invalid expression: s:dark

tlemens commented 6 years ago

Same here with Mate Terminal 1.18.2 @jonsmithers solution works for me