diff --git a/autoload/lightline/colorscheme.vim b/autoload/lightline/colorscheme.vim index de23eb5..6bf1be2 100644 --- a/autoload/lightline/colorscheme.vim +++ b/autoload/lightline/colorscheme.vim @@ -2,7 +2,7 @@ " Filename: autoload/lightline/colorscheme.vim " Author: itchyny " License: MIT License -" Last Change: 2015/03/18 08:37:17. +" Last Change: 2017/11/28 21:25:13. " ============================================================================= let s:save_cpo = &cpo @@ -224,5 +224,32 @@ function! lightline#colorscheme#flatten(p) abort return a:p endfunction +if has('gui_running') + function! lightline#colorscheme#background() abort + return &background + endfunction +else + " &background is set inappropriately when the colorscheme sets ctermbg of the Normal group + function! lightline#colorscheme#background() abort + let bg_color = synIDattr(synIDtrans(hlID('Normal')), 'bg', 'cterm') + if bg_color !=# '' + if bg_color < 8 || 232 <= bg_color && bg_color < 244 + return 'dark' + elseif 8 <= bg_color && bg_color < 16 || 244 <= bg_color + return 'light' + endif + endif + let fg_color = synIDattr(synIDtrans(hlID('Normal')), 'fg', 'cterm') + if fg_color !=# '' + if fg_color < 8 || 232 <= fg_color && fg_color < 244 + return 'light' + elseif 8 <= fg_color && fg_color < 16 || 244 <= fg_color + return 'dark' + endif + endif + return &background + endfunction +endif + let &cpo = s:save_cpo unlet s:save_cpo diff --git a/autoload/lightline/colorscheme/16color.vim b/autoload/lightline/colorscheme/16color.vim index 170aa93..41e6497 100644 --- a/autoload/lightline/colorscheme/16color.vim +++ b/autoload/lightline/colorscheme/16color.vim @@ -2,8 +2,9 @@ " Filename: autoload/lightline/colorscheme/16color.vim " Author: itchyny " License: MIT License -" Last Change: 2014/01/02 10:04:03. +" Last Change: 2017/11/25 11:14:04. " ============================================================================= + let s:base03 = [ '#808080', 8 ] let s:base02 = [ '#000000', 0 ] let s:base01 = [ '#00ff00', 10 ] @@ -20,12 +21,14 @@ let s:violet = [ '#ff00ff', 13 ] let s:blue = [ '#000080', 4 ] let s:cyan = [ '#008080', 6 ] let s:green = [ '#008000', 2 ] -if &background ==# 'light' + +if lightline#colorscheme#background() ==# 'light' let [s:base03, s:base3] = [s:base3, s:base03] let [s:base02, s:base2] = [s:base2, s:base02] let [s:base01, s:base1] = [s:base1, s:base01] let [s:base00, s:base0] = [s:base0, s:base00] endif + let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} let s:p.normal.left = [ [ s:base3, s:blue ], [ s:base3, s:base01 ] ] let s:p.normal.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ] diff --git a/autoload/lightline/colorscheme/PaperColor.vim b/autoload/lightline/colorscheme/PaperColor.vim index 429439d..90aa426 100644 --- a/autoload/lightline/colorscheme/PaperColor.vim +++ b/autoload/lightline/colorscheme/PaperColor.vim @@ -2,10 +2,10 @@ " Filename: autoload/lightline/colorscheme/PaperColor.vim " Author: TKNGUE " License: MIT License -" Last Change: 2015/07/28 07:35:00. +" Last Change: 2017/11/25 11:13:35. " ============================================================================= -if &background ==# 'light' +if lightline#colorscheme#background() ==# 'light' let g:lightline#colorscheme#PaperColor#palette = g:lightline#colorscheme#PaperColor_light#palette else let g:lightline#colorscheme#PaperColor#palette = g:lightline#colorscheme#PaperColor_dark#palette diff --git a/autoload/lightline/colorscheme/materia.vim b/autoload/lightline/colorscheme/materia.vim index ba44f3d..fdab2cb 100644 --- a/autoload/lightline/colorscheme/materia.vim +++ b/autoload/lightline/colorscheme/materia.vim @@ -2,7 +2,7 @@ " Filename: autoload/lightline/colorscheme/materia.vim " Author: Lokesh Krishna " License: MIT License -" Last Change: 2017/10/21 11:32:27. +" Last Change: 2017/11/25 11:13:40. " ============================================================================= " Common colors @@ -16,7 +16,7 @@ let s:yellow = '#ffcc00' let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} -if &background ==# 'light' +if lightline#colorscheme#background() ==# 'light' " Light variant let s:bg = '#ffffff' let s:gray1 = '#2c393f' diff --git a/autoload/lightline/colorscheme/material.vim b/autoload/lightline/colorscheme/material.vim index eb2428f..0d704b7 100644 --- a/autoload/lightline/colorscheme/material.vim +++ b/autoload/lightline/colorscheme/material.vim @@ -2,7 +2,7 @@ " Filename: autoload/lightline/colorscheme/material.vim " Author: Lokesh Krishna " License: MIT License -" Last Change: 2017/10/30 16:35:27. +" Last Change: 2017/11/25 11:13:42. " ============================================================================= " Common colors @@ -16,7 +16,7 @@ let s:yellow = '#ffcb6b' let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} -if &background ==# 'light' +if lightline#colorscheme#background() ==# 'light' " Light variant let s:bg = '#ffffff' let s:gray1 = '#2e3c43' diff --git a/autoload/lightline/colorscheme/one.vim b/autoload/lightline/colorscheme/one.vim index f50de8c..50fb177 100644 --- a/autoload/lightline/colorscheme/one.vim +++ b/autoload/lightline/colorscheme/one.vim @@ -2,7 +2,7 @@ " Filename: autoload/lightline/colorscheme/one.vim " Author: Zoltan Dalmadi " License: MIT License -" Last Change: 2016/11/2 17:34:27. +" Last Change: 2017/11/25 11:13:44. " ============================================================================= " Common colors @@ -16,7 +16,7 @@ let s:yellow = '#e5c07b' let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} -if &background ==# 'light' +if lightline#colorscheme#background() ==# 'light' " Light variant let s:bg = '#fafafa' let s:gray1 = '#494b53' diff --git a/autoload/lightline/colorscheme/solarized.vim b/autoload/lightline/colorscheme/solarized.vim index 577177e..d6ee9c6 100644 --- a/autoload/lightline/colorscheme/solarized.vim +++ b/autoload/lightline/colorscheme/solarized.vim @@ -2,7 +2,7 @@ " Filename: autoload/lightline/colorscheme/solarized.vim " Author: itchyny " License: MIT License -" Last Change: 2016/08/08 10:31:00. +" Last Change: 2017/11/25 11:13:46. " ============================================================================= let s:cuicolors = { @@ -53,7 +53,7 @@ let s:blue = [ '#268bd2', s:cuicolors.blue[s:cuiindex] ] let s:cyan = [ '#2aa198', s:cuicolors.cyan[s:cuiindex] ] let s:green = [ '#859900', s:cuicolors.green[s:cuiindex] ] -if &background ==# 'light' +if lightline#colorscheme#background() ==# 'light' let [ s:base03, s:base3 ] = [ s:base3, s:base03 ] let [ s:base02, s:base2 ] = [ s:base2, s:base02 ] let [ s:base01, s:base1 ] = [ s:base1, s:base01 ]