I am trying to import variables set in another.vim file and use them in my script.
The fist script colors-wal.vim
" Special
let wallpaper = "cyb285r5j1w31.png"
let background = "#020303"
let foreground = "#e2cdc2"
let cursor = "#e2cdc2"
" Colors
let color0 = "#020303"
let color1 = "#B09747"
let color2 = "#A1A958"
let color3 = "#ACB258"
let color4 = "#D09B60"
let color5 = "#E8D36E"
let color6 = "#D7AF94"
let color7 = "#e2cdc2"
let color8 = "#9e8f87"
let color9 = "#B09747"
let color10 = "#A1A958"
let color11 = "#ACB258"
let color12 = "#D09B60"
let color13 = "#E8D36E"
let color14 = "#D7AF94"
let color15 = "#e2cdc2"
"My" script taken from wal.vim and updated to work with termguicolors
hi clear
set background=dark
if exists('syntax_on')
syntax reset
endif
" Colorscheme name
let g:colors_name = 'wal-test'
source ~/.cache/wal/colors-wal.vim
let g:theTest=color1
hi Normal ctermbg=NONE guifg=color7 ctermfg=7
hi NonText ctermbg=NONE guifg=color0 ctermfg=0
hi Comment ctermbg=NONE guifg=color8 ctermfg=8
hi Conceal ctermbg=NONE
hi Constant ctermbg=NONE guifg=color3 ctermfg=3
hi Error guibg=color1 ctermbg=1 guifg=color7 ctermfg=7
hi Identifier ctermbg=NONE guifg=color1 ctermfg=1 gui=BOLD cterm=BOLD
hi Ignore guibg=color8 ctermbg=8 guifg=color0 ctermfg=0
hi PreProc ctermbg=NONE guifg=color3 ctermfg=3
I truncated the script and removed most comments, but there are no errors given by Vim and its just more of the same. The colorscheme is set properly because when I unset it I get nvims native color scheme.
:echo theTest
Returns #B09747
:hi Normal ctermbg=NONE guifg=#B09747 ctermfg=7
changes the normal text color as expected.
:hi Normal ctermbg=NONE guifg=theTest ctermfg=7
does "nothing", it will unset the command above.
I am not sure what exactly to try. I though maybe concatenation, so i did guifg=. theTest
guifg=. theTest
, but it returns an error that says E416: missing equal sign, which I have looked up, but am maybe to novice to understand. Any ideas?
Unless there is another way, it must be run as a script in order to substitute the variable meaningfully.
For example
:hi Normal ctermbg=NONE guifg=theTest ctermfg=7
should be
:execute "hi Normal ctermbg=NONE guifg=". theTest. " ctermfg=7"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.