I'm trying to make a colorscheme configurable where I define the style in a variable defined in my .vimrc.let g:plugin_style='<vim-highlighting-style>'Then in the colorscheme I'm doing:highlight! StyleName g:plugin_styleThis doesn't work, hightlight! uses the literal g:plugin_style.I tried as well to use execexec 'highlight! StyleName ' . g:plugin_styleThis doesn't work neither, StyleName is not known afterwards.How to do this in vimscript?
How to use a variable value in a colorscheme
colorscheme;highlight;variables
As @Jamessan suggested in this SO answer, using execute should work properly.Firs the variable should be defined like this:let g:plugin_style='term=bold ctermfg=Cyan guifg=#80a0ff gui=bold'See :h highlight-args for the values that this variable can take.Then simply use:execute 'highlight [default] {group-name} ' . g:plugin_styleFinally an important note is to define the variable before you call your colorscheme otherwise the colorscheme cannot know the value of the variable.