From 0e92073db15d495e2fd798151474764ac9909aa9 Mon Sep 17 00:00:00 2001 From: Zhaosheng Pan Date: Sun, 31 May 2020 15:11:45 +0800 Subject: [PATCH] Support change background according to the 'background' option --- README.md | 6 +++++- autoload/airline/themes/ayu.vim | 2 +- autoload/lightline/colorscheme/ayu.vim | 2 +- colors/ayu.vim | 8 +------- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 982a59f..d45a845 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,13 @@ Plug 'ayu-theme/ayu-vim' " or other package manager "... set termguicolors " enable true colors support -let ayucolor="light" " for light version of theme + +set background=light " for light version of theme + +set background=dark " for mirage or dark version of theme let ayucolor="mirage" " for mirage version of theme let ayucolor="dark" " for dark version of theme + colorscheme ayu ``` diff --git a/autoload/airline/themes/ayu.vim b/autoload/airline/themes/ayu.vim index 2818f77..137beae 100644 --- a/autoload/airline/themes/ayu.vim +++ b/autoload/airline/themes/ayu.vim @@ -3,7 +3,7 @@ " Let's store all the colors in a dictionary. let s:c = {} -let s:ayucolor = get(g:, 'ayucolor', 'dark') +let s:ayucolor = &background ==# 'dark' ? get(g:, 'ayucolor', 'dark') : &background if s:ayucolor == 'light' " Base colors. diff --git a/autoload/lightline/colorscheme/ayu.vim b/autoload/lightline/colorscheme/ayu.vim index ae528b4..2158c8e 100644 --- a/autoload/lightline/colorscheme/ayu.vim +++ b/autoload/lightline/colorscheme/ayu.vim @@ -1,4 +1,4 @@ -let s:style = get(g:, 'ayucolor', 'dark') +let s:style = &background ==# 'dark' ? get(g:, 'ayucolor', 'dark') : &background let s:fg = {} let s:fg.primary = {'dark': '#E6E1CF', 'light': '#5C6773', 'mirage': '#D9D7CE'}[s:style] diff --git a/colors/ayu.vim b/colors/ayu.vim index 9158e6b..a30c763 100644 --- a/colors/ayu.vim +++ b/colors/ayu.vim @@ -5,7 +5,7 @@ if exists("syntax_on") syntax reset endif -let s:style = get(g:, 'ayucolor', 'dark') +let s:style = &background ==# 'dark' ? get(g:, 'ayucolor', 'dark') : &background let g:colors_name = "ayu" "}}} @@ -269,9 +269,3 @@ hi! link diffAdded String " diffComment "}}} -" -" This is needed for some reason: {{{ - -let &background = s:style - -" }}}