I'm hacking on the lightline plugin of vim (downloaded version). I can modify the colors of each themes. I did something that works well in the powerline.vim scheme (path : ~/.vim/pack/plugins/start/lightline/autoload/lightline/colorscheme/powerline.vim)
Now I want the colortheme to change while I'm in vim. I added this code in the begining of powerline.vim :
10 let s:BSsplitscolor = "'darkestgreen', 'brightgreen'"
11 if g:BSsplitsbool == "1"
12 let s:BSsplitscolor = "'gray4', 'brightorange'"
13 endif
14
15 " ============================== NOTE: below : already there
16
17 let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}}
18 let s:p.normal.left = [ [s:BSsplitscolor, 'bold'], ['white', 'gray4'] ]
Here s:BSsplitscolor contains the colors I want : it's either 'gray4', 'brightorange' if g:BSsplitsbool equals 1 or 'darkestgreen', 'brightgreen' if not. It's g:BSsplitsbool that changes.
Now the problem is at the 16th line : when I add s:BSsplitscolor after [ [, I get these errors when I restart vim (translate from french) :
Error detected while treating functionlightline#update[5]..lightline#colorscheme[18]..lightline#highlight :
line 18 :
E254: can not allocate color darkestgreen
E416: missing '=' : , 'brightgreen' guibg=bold ctermfg=0 ctermbg=0
Error detected while treating function lightline#update :
line 5 :
E171: missing :endif
I think I'm missing something... I'm not so good at vim scripting : I can do an if instruction, remap, and that's all.
First, the solution:
Second, the explanation:
You are trying to build a list of three items:
out of a string that vaguely looks like a list:
and a list with a single string:
by inserting that string in that list:
which gives you this monstrosity:
which is a list of two items, not at all what you are trying to build. I'm not aware of a scripting language where something like that could be expected to work.
The actual solution is to make
s:BSsplitscolora list:and merge it with
['bold']. This can be done in several ways. With:help expr-+:or with
:help extend():