diff options
author | Johnny Oskarsson <johnny@joskar.se> | 2020-10-24 13:14:25 +0200 |
---|---|---|
committer | Johnny Oskarsson <johnny@joskar.se> | 2020-10-24 13:27:49 +0200 |
commit | c8a7da6f5fa890a621d4fec11ef09c9b3559f32a (patch) | |
tree | c9ef1a5b1c0ad66dde0a68cbf6480555c3bc313c /templates | |
parent | 6191622d5806d4448fa2285047936bdcee57a098 (diff) |
Add support for GUI special names ("NONE", ...)
The motivation for this is primarily to be able to set `guibg=NONE` in
order to support transparent backgrounds in terminals, which was
previously not possible due to `Base16hi()` assuming that every color is a
hex value.
Diffstat (limited to 'templates')
-rw-r--r-- | templates/default.mustache | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/templates/default.mustache b/templates/default.mustache index e0b612c..ddd36bc 100644 --- a/templates/default.mustache +++ b/templates/default.mustache @@ -153,11 +153,22 @@ function! g:Base16hi(group, guifg, guibg, ctermfg, ctermbg, ...) let l:attr = get(a:, 1, "") let l:guisp = get(a:, 2, "") + " See :help highlight-guifg + let l:gui_special_names = ["NONE", "bg", "background", "fg", "foreground"] + if a:guifg != "" - exec "hi " . a:group . " guifg=#" . a:guifg + if index(l:gui_special_names, a:guifg) >= 0 + exec "hi " . a:group . " guifg=" . a:guifg + else + exec "hi " . a:group . " guifg=#" . a:guifg + endif endif if a:guibg != "" - exec "hi " . a:group . " guibg=#" . a:guibg + if index(l:gui_special_names, a:guibg) >= 0 + exec "hi " . a:group . " guibg=" . a:guibg + else + exec "hi " . a:group . " guibg=#" . a:guibg + endif endif if a:ctermfg != "" exec "hi " . a:group . " ctermfg=" . a:ctermfg @@ -169,7 +180,11 @@ function! g:Base16hi(group, guifg, guibg, ctermfg, ctermbg, ...) exec "hi " . a:group . " gui=" . l:attr . " cterm=" . l:attr endif if l:guisp != "" - exec "hi " . a:group . " guisp=#" . l:guisp + if index(l:gui_special_names, l:guisp) >= 0 + exec "hi " . a:group . " guisp=" . l:guisp + else + exec "hi " . a:group . " guisp=#" . l:guisp + endif endif endfunction |