terminal: Some improvements to Terminal detection

closes #1730

- Make sure to always call the term extension on TermOpen autocommands
- consistently use the airline_term highlighting group
- hard code the airline_term highlighting group, because by the time the
  function airline#themes#patch() is called the highlighting group
  airline_c would no be defined, so we cannot dynamically get those
  attributes
- In the documentation, mention how the g:airline_mode_map can be set
  including the terminal section
This commit is contained in:
Christian Brabandt 2018-06-04 22:44:46 +02:00
parent 1bb1ce594a
commit eab6d35852
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
4 changed files with 9 additions and 4 deletions

View File

@ -7,9 +7,10 @@ function! airline#extensions#term#apply(...)
if &buftype == 'terminal'
let spc = g:airline_symbols.space
call a:1.add_section('airline_a', spc.'TERMINAL'.spc)
let name=get(g:airline_mode_map, 't', 't')
call a:1.add_section('airline_a', spc.name.spc)
call a:1.add_section('airline_b', '')
call a:1.add_section('airline_c', spc.'%f')
call a:1.add_section('airline_term', spc.'%f')
call a:1.split()
call a:1.add_section('airline_y', '')
call a:1.add_section('airline_z', spc.airline#section#create_right(['linenr', 'maxlinenr']))

View File

@ -45,8 +45,7 @@ function! airline#themes#patch(palette)
let a:palette[mode]['airline_error'] = [ '#000000', '#990000', 232, 160 ]
endif
if !has_key(a:palette[mode], 'airline_term')
"let a:palette[mode]['airline_term'] = [ '#9cffd3', '#202020', 85, 232]
let a:palette[mode]['airline_term'] = airline#highlighter#get_highlight('airline_c')
let a:palette[mode]['airline_term'] = [ '#9cffd3', '#202020', 85, 232]
endif
endfor

View File

@ -184,6 +184,7 @@ values):
\ 's' : 'S',
\ 'S' : 'S',
\ '' : 'S',
\ 't' : 'T',
\ }
<
* define the set of filename match queries which excludes a window from having

View File

@ -99,6 +99,10 @@ function! s:airline_toggle()
" Make sure that g_airline_gui_mode is refreshed
autocmd OptionSet termguicolors call <sid>on_colorscheme_changed()
endif
if exists("##TerminalOpen")
" Make sure that g_airline_gui_mode is refreshed
autocmd TerminalOpen * call <sid>on_colorscheme_changed()
endif
" Refresh airline for :syntax off
autocmd SourcePre */syntax/syntax.vim
\ call airline#extensions#tabline#buffers#invalidate()