fix neovim color mode

This commit is contained in:
Christian Brabandt 2016-02-05 22:19:48 +01:00
parent fdb74f549d
commit 87d60febaf
5 changed files with 19 additions and 10 deletions

View File

@ -77,7 +77,7 @@ function! s:should_change_group(group1, group2)
endif endif
let color1 = airline#highlighter#get_highlight(a:group1) let color1 = airline#highlighter#get_highlight(a:group1)
let color2 = airline#highlighter#get_highlight(a:group2) let color2 = airline#highlighter#get_highlight(a:group2)
if has('gui_running') || has('nvim') || (has("termtruecolor") && &guicolors == 1) if g:airline_gui_mode ==# 'gui'
return color1[1] != color2[1] || color1[0] != color2[0] return color1[1] != color2[1] || color1[0] != color2[0]
else else
return color1[3] != color2[3] || color1[2] != color2[2] return color1[3] != color2[3] || color1[2] != color2[2]

View File

@ -12,7 +12,7 @@ endif
function! airline#extensions#tabline#init(ext) function! airline#extensions#tabline#init(ext)
if has('nvim') || has('gui_running') if has('gui_running')
set guioptions-=e set guioptions-=e
endif endif

View File

@ -17,14 +17,15 @@ function! s:gui2cui(rgb, fallback)
endfunction endfunction
function! s:get_syn(group, what) function! s:get_syn(group, what)
" need to pass in mode, known to break on 7.3.547 if !exists("g:airline_gui_mode")
let mode = has('nvim') || has('gui_running') || (has("termtruecolor") && &guicolors == 1) ? 'gui' : 'cterm' let g:airline_gui_mode = airline#init#gui_mode()
let color = synIDattr(synIDtrans(hlID(a:group)), a:what, mode) endif
let color = synIDattr(synIDtrans(hlID(a:group)), a:what, g:airline_gui_mode)
if empty(color) || color == -1 if empty(color) || color == -1
let color = synIDattr(synIDtrans(hlID('Normal')), a:what, mode) let color = synIDattr(synIDtrans(hlID('Normal')), a:what, g:airline_gui_mode)
endif endif
if empty(color) || color == -1 if empty(color) || color == -1
if has('nvim') || has('gui_running') || (has("termtruecolor") && &guicolors == 1) if g:airline_gui_mode ==# 'gui'
let color = a:what ==# 'fg' ? '#000000' : '#FFFFFF' let color = a:what ==# 'fg' ? '#000000' : '#FFFFFF'
else else
let color = a:what ==# 'fg' ? 0 : 1 let color = a:what ==# 'fg' ? 0 : 1
@ -36,7 +37,7 @@ endfunction
function! s:get_array(fg, bg, opts) function! s:get_array(fg, bg, opts)
let fg = a:fg let fg = a:fg
let bg = a:bg let bg = a:bg
return has('nvim') || has('gui_running') || (has("termtruecolor") && &guicolors == 1) return g:airline_gui_mode ==# 'gui'
\ ? [ fg, bg, '', '', join(a:opts, ',') ] \ ? [ fg, bg, '', '', join(a:opts, ',') ]
\ : [ '', '', fg, bg, join(a:opts, ',') ] \ : [ '', '', fg, bg, join(a:opts, ',') ]
endfunction endfunction
@ -44,7 +45,7 @@ endfunction
function! airline#highlighter#get_highlight(group, ...) function! airline#highlighter#get_highlight(group, ...)
let fg = s:get_syn(a:group, 'fg') let fg = s:get_syn(a:group, 'fg')
let bg = s:get_syn(a:group, 'bg') let bg = s:get_syn(a:group, 'bg')
let reverse = has('nvim') || has('gui_running') || (has("termtruecolor") && &guicolors == 1) let reverse = g:airline_gui_mode ==# 'gui'
\ ? synIDattr(synIDtrans(hlID(a:group)), 'reverse', 'gui') \ ? synIDattr(synIDtrans(hlID(a:group)), 'reverse', 'gui')
\ : synIDattr(synIDtrans(hlID(a:group)), 'reverse', 'cterm') \ : synIDattr(synIDtrans(hlID(a:group)), 'reverse', 'cterm')
\|| synIDattr(synIDtrans(hlID(a:group)), 'reverse', 'term') \|| synIDattr(synIDtrans(hlID(a:group)), 'reverse', 'term')

View File

@ -27,6 +27,7 @@ function! airline#init#bootstrap()
call s:check_defined('g:airline_exclude_filenames', ['DebuggerWatch','DebuggerStack','DebuggerStatus']) call s:check_defined('g:airline_exclude_filenames', ['DebuggerWatch','DebuggerStack','DebuggerStatus'])
call s:check_defined('g:airline_exclude_filetypes', []) call s:check_defined('g:airline_exclude_filetypes', [])
call s:check_defined('g:airline_exclude_preview', 0) call s:check_defined('g:airline_exclude_preview', 0)
call s:check_defined('g:airline_gui_mode', airline#init#gui_mode())
call s:check_defined('g:airline_mode_map', {}) call s:check_defined('g:airline_mode_map', {})
call extend(g:airline_mode_map, { call extend(g:airline_mode_map, {
@ -92,6 +93,12 @@ function! airline#init#bootstrap()
unlet g:airline#init#bootstrapping unlet g:airline#init#bootstrapping
endfunction endfunction
function! airline#init#gui_mode()
return ((has('nvim') && exists('$NVIM_TUI_ENABLE_TRUE_COLOR'))
\ || has('gui_running') || (has("termtruecolor") && &guicolors == 1)) ?
\ 'gui' : 'cterm'
endfunction
function! airline#init#sections() function! airline#init#sections()
let spc = g:airline_symbols.space let spc = g:airline_symbols.space
if !exists('g:airline_section_a') if !exists('g:airline_section_a')

View File

@ -43,6 +43,7 @@ endfunction
function! s:on_colorscheme_changed() function! s:on_colorscheme_changed()
call s:init() call s:init()
let g:airline_gui_mode = airline#init#gui_mode()
if !s:theme_in_vimrc if !s:theme_in_vimrc
call airline#switch_matching_theme() call airline#switch_matching_theme()
endif endif
@ -77,7 +78,7 @@ function! s:airline_toggle()
\ | call <sid>on_window_changed() \ | call <sid>on_window_changed()
autocmd CmdwinLeave * call airline#remove_statusline_func('airline#cmdwinenter') autocmd CmdwinLeave * call airline#remove_statusline_func('airline#cmdwinenter')
autocmd ColorScheme * call <sid>on_colorscheme_changed() autocmd GUIEnter,ColorScheme * call <sid>on_colorscheme_changed()
autocmd VimEnter,WinEnter,BufWinEnter,FileType,BufUnload,VimResized * autocmd VimEnter,WinEnter,BufWinEnter,FileType,BufUnload,VimResized *
\ call <sid>on_window_changed() \ call <sid>on_window_changed()