term: allow to customize section_a and section_z

closes: #2647
This commit is contained in:
Christian Brabandt 2023-07-13 16:47:35 +02:00
parent 423fe9e2ac
commit cead8efb48
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
2 changed files with 32 additions and 9 deletions

View File

@ -6,31 +6,46 @@ scriptencoding utf-8
call airline#parts#define_function('tmode', 'airline#extensions#term#termmode')
call airline#parts#define('terminal', {'text': get(g:airline_mode_map, 't', 't'), 'accent': 'bold'})
let s:spc = g:airline_symbols.space
let s:section_a = airline#section#create_left(['terminal', 'tmode'])
let s:section_z = airline#section#create(['linenr', 'maxlinenr'])
function! s:GetAirlineSection()
if exists("g:airline_section_z_term")
let section_z = g:airline_section_z_term
else
let section_z = airline#section#create(['linenr', 'maxlinenr'])
endif
if exists("g:airline_section_a_term")
let section_a = g:airline_section_a_term
else
let section_a = airline#section#create_left(['terminal', 'tmode'])
endif
return [section_a, section_z]
endfunction
function! airline#extensions#term#apply(...) abort
if &buftype ==? 'terminal' || bufname(a:2.bufnr)[0] ==? '!'
call a:1.add_section_spaced('airline_a', s:section_a)
let sections = s:GetAirlineSection()
let spc = g:airline_symbols.space
call a:1.add_section_spaced('airline_a', sections[0])
call a:1.add_section_spaced('airline_b', s:neoterm_id(a:2.bufnr))
call a:1.add_section('airline_term', s:spc.s:termname(a:2.bufnr))
call a:1.add_section('airline_term', spc.s:termname(a:2.bufnr))
call a:1.split()
call a:1.add_section('airline_y', '')
call a:1.add_section_spaced('airline_z', s:section_z)
call a:1.add_section_spaced('airline_z', sections[1])
return 1
endif
endfunction
function! airline#extensions#term#inactive_apply(...) abort
if getbufvar(a:2.bufnr, '&buftype') ==? 'terminal'
call a:1.add_section_spaced('airline_a', s:section_a)
let sections = s:GetAirlineSection()
let spc = g:airline_symbols.space
call a:1.add_section_spaced('airline_a', sections[0])
call a:1.add_section_spaced('airline_b', s:neoterm_id(a:2.bufnr))
call a:1.add_section('airline_term', s:spc.s:termname(a:2.bufnr))
call a:1.add_section('airline_term', spc.s:termname(a:2.bufnr))
call a:1.split()
call a:1.add_section('airline_y', '')
call a:1.add_section_spaced('airline_z', s:section_z)
call a:1.add_section_spaced('airline_z', sections[1])
return 1
endif
endfunction

View File

@ -1446,6 +1446,14 @@ Vim-Airline comes with a small extension for the styling the builtin
let g:airline#extensions#term#enabled = 1
default: 1
* Use custom section_z >
let g:airline_section_z_term = '%p%% ☰ %l/%L, %v'
default: airline#section#create(['linenr', 'maxlinenr'])
* Use custom section_a >
let g:airline_section_a_term = '%p%% ☰ %l/%L, %v'
default: airline#section#create_left(['terminal', 'tmode'])
------------------------------------- *airline-tabws*
vim-tabws <https://github.com/s1341/vim-tabws>