terminal: return proper terminal name

This commit is contained in:
Christian Brabandt 2018-11-20 16:11:34 +01:00
parent f9ccb57e76
commit bc63a60b0f
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
2 changed files with 12 additions and 2 deletions

View File

@ -149,7 +149,7 @@ function! airline#extensions#load()
call add(s:loaded_ext, 'netrw')
endif
if has("terminal")
if has("terminal") || has('nvim')
call airline#extensions#term#init(s:ext)
call add(s:loaded_ext, 'term')
endif

View File

@ -10,7 +10,7 @@ function! airline#extensions#term#apply(...)
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_term', spc.'%f')
call a:1.add_section('airline_term', spc.s:termname())
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']))
@ -18,6 +18,16 @@ function! airline#extensions#term#apply(...)
endif
endfunction
function! s:termname()
let bufname = bufname('%')
if has('nvim')
return matchstr(bufname, 'term.*:\zs.*')
else
" get rid of leading '!'
return bufname[1:]
endif
endfunction
function! airline#extensions#term#init(ext)
call a:ext.add_statusline_func('airline#extensions#term#apply')
endfunction