diff --git a/autoload/zenbones/util.vim b/autoload/zenbones/util.vim new file mode 100644 index 0000000..0845ed6 --- /dev/null +++ b/autoload/zenbones/util.vim @@ -0,0 +1,17 @@ +function! zenbones#util#setup_colorscheme(...) abort + if exists('g:colors_name') + highlight clear + endif + + let g:colors_name = a:1 + let l:bg = a:0 == 2 ? a:2 : v:null + if l:bg + set background=l:bg + endif + + if has('nvim') && (!exists('g:' . g:colors_name . '_compat') || g:{g:colors_name}_compat == 0) + lua require("zenbones.util").apply_colorscheme() + else + call {g:colors_name . l:bg ? '_' . l:bg : ''}#load() + endif +endfunction diff --git a/colors/zenbones.vim b/colors/zenbones.vim index 4b4adbc..9a779b5 100644 --- a/colors/zenbones.vim +++ b/colors/zenbones.vim @@ -1,11 +1 @@ -if exists('g:colors_name') - highlight clear -endif - -let g:colors_name = 'zenbones' - -if has('nvim') && (!exists('g:' . g:colors_name . '_compat') || g:{g:colors_name}_compat == 0) - lua require("zenbones.util").apply_colorscheme() -else - call {g:colors_name . '_' . &background}#load() -endif +call zenbones#util#setup_colorscheme('zenbones')