From eab6d358523ad7c89115efaf688c999de29f6982 Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Mon, 4 Jun 2018 22:44:46 +0200 Subject: [PATCH] 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 --- autoload/airline/extensions/term.vim | 5 +++-- autoload/airline/themes.vim | 3 +-- doc/airline.txt | 1 + plugin/airline.vim | 4 ++++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/autoload/airline/extensions/term.vim b/autoload/airline/extensions/term.vim index b4d1d1bd..5e562e2e 100644 --- a/autoload/airline/extensions/term.vim +++ b/autoload/airline/extensions/term.vim @@ -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'])) diff --git a/autoload/airline/themes.vim b/autoload/airline/themes.vim index f6dd10f5..5379c028 100644 --- a/autoload/airline/themes.vim +++ b/autoload/airline/themes.vim @@ -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 diff --git a/doc/airline.txt b/doc/airline.txt index 1531046c..ec3f37e4 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -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 diff --git a/plugin/airline.vim b/plugin/airline.vim index 34870c43..20efa26f 100644 --- a/plugin/airline.vim +++ b/plugin/airline.vim @@ -99,6 +99,10 @@ function! s:airline_toggle() " Make sure that g_airline_gui_mode is refreshed autocmd OptionSet termguicolors call on_colorscheme_changed() endif + if exists("##TerminalOpen") + " Make sure that g_airline_gui_mode is refreshed + autocmd TerminalOpen * call on_colorscheme_changed() + endif " Refresh airline for :syntax off autocmd SourcePre */syntax/syntax.vim \ call airline#extensions#tabline#buffers#invalidate()