Add a terminal statusline function for vim

This commit is contained in:
Christian Brabandt 2017-08-22 15:30:15 +02:00
parent bd613e69b6
commit 0ad4f97c1a
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
4 changed files with 44 additions and 1 deletions

View File

@ -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

View File

@ -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')

View File

@ -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

View File

@ -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', {})