diff --git a/autoload/airline/builder.vim b/autoload/airline/builder.vim index d87ddfeb..7c74226d 100644 --- a/autoload/airline/builder.vim +++ b/autoload/airline/builder.vim @@ -49,7 +49,9 @@ function! s:prototype.build() dict let contents = section[1] let pgroup = prev_group let prev_group = s:get_prev_group(self._sections, i) - if group ==# 'airline_c' && !self._context.active && has_key(self._context, 'bufnr') + if group ==# 'airline_c' && &buftype ==# 'terminal' && self._context.active + let group = 'airline_term' + elseif group ==# 'airline_c' && !self._context.active && has_key(self._context, 'bufnr') let group = 'airline_c'. self._context.bufnr elseif prev_group ==# 'airline_c' && !self._context.active && has_key(self._context, 'bufnr') let prev_group = 'airline_c'. self._context.bufnr diff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim index 67ec77f2..79f6bec0 100644 --- a/autoload/airline/extensions.vim +++ b/autoload/airline/extensions.vim @@ -153,6 +153,11 @@ function! airline#extensions#load() call add(loaded_ext, 'netrw') endif + if has("terminal") + call airline#extensions#term#init(s:ext) + call add(loaded_ext, 'term') + endif + if get(g:, 'airline#extensions#ycm#enabled', 0) call airline#extensions#ycm#init(s:ext) call add(loaded_ext, 'ycm') diff --git a/autoload/airline/extensions/term.vim b/autoload/airline/extensions/term.vim new file mode 100644 index 00000000..705b1ef0 --- /dev/null +++ b/autoload/airline/extensions/term.vim @@ -0,0 +1,32 @@ +" MIT License. +" vim: et ts=2 sts=2 sw=2 + +scriptencoding utf-8 + +function! airline#extensions#term#apply(...) + if &buftype == 'terminal' + let spc = g:airline_symbols.space + + call a:1.add_section('airline_a', spc.'TERMINAL'.spc) + call a:1.add_section('airline_b', '') + call a:1.add_section('airline_c', 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'])) + redraw! + return 1 + "let w:airline_section_b = '' + "let w:airline_section_x = '' + " Here we define a new part for the plugin. This allows users to place this + " extension in arbitrary locations. + "call airline#parts#define_raw('term', '%{airline#extensions#term#get_highlight()}') + + " Next up we add a funcref so that we can run some code prior to the + " statusline getting modifed. + "call a:ext.add_statusline_func('airline#extensions#term#apply') + endif +endfunction + +function! airline#extensions#term#init(ext) + call a:ext.add_statusline_func('airline#extensions#term#apply') +endfunction diff --git a/autoload/airline/themes.vim b/autoload/airline/themes.vim index 75c2f40d..1de4c38b 100644 --- a/autoload/airline/themes.vim +++ b/autoload/airline/themes.vim @@ -44,6 +44,10 @@ function! airline#themes#patch(palette) if !has_key(a:palette[mode], 'airline_error') 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') + endif endfor let a:palette.accents = get(a:palette, 'accents', {})