tabline: refactor label function

This commit is contained in:
Christian Brabandt 2018-01-04 18:43:03 +01:00
parent 3985ece131
commit 3b631ef0c4
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
3 changed files with 10 additions and 12 deletions

View File

@ -201,3 +201,10 @@ function! airline#extensions#tabline#group_of_bufnr(tab_bufs, bufnr)
endif endif
return group return group
endfunction endfunction
function! airline#extensions#tabline#add_label(dict, type)
if get(g:, 'airline#extensions#tabline#show_tab_type', 1)
call a:dict.add_section_spaced('airline_tab',
\ get(g:, 'airline#extensions#tabline#'.a:type.'_label', '['.a:type.']'))
endif
endfunction

View File

@ -97,10 +97,7 @@ function! airline#extensions#tabline#buffers#get()
call b.add_section('airline_tabfill', '') call b.add_section('airline_tabfill', '')
call b.split() call b.split()
call b.add_section('airline_tabfill', '') call b.add_section('airline_tabfill', '')
if get(g:, 'airline#extensions#tabline#show_tab_type', 1) call airline#extensions#tabline#add_label(b, 'buffers')
call b.add_section_spaced('airline_tab',
\ get(g:, 'airline#extensions#tabline#buffers_label', '[buffers]'))
endif
if tabpagenr('$') > 1 if tabpagenr('$') > 1
call b.add_section_spaced('airline_tabmod', printf('%s %d/%d', "tab", tabpagenr(), tabpagenr('$'))) call b.add_section_spaced('airline_tabmod', printf('%s %d/%d', "tab", tabpagenr(), tabpagenr('$')))

View File

@ -42,10 +42,7 @@ function! airline#extensions#tabline#tabs#get()
let tab_nr_type = get(g:, 'airline#extensions#tabline#tab_nr_type', 0) let tab_nr_type = get(g:, 'airline#extensions#tabline#tab_nr_type', 0)
let b = airline#extensions#tabline#new_builder() let b = airline#extensions#tabline#new_builder()
if get(g:, 'airline#extensions#tabline#show_tab_type', 1) call airline#extensions#tabline#add_label(b, 'buffers')
call b.add_section_spaced('airline_tab',
\ get(g:, 'airline#extensions#tabline#buffers_label', '[buffers]'))
endif
for i in range(1, tabpagenr('$')) for i in range(1, tabpagenr('$'))
if i == curtab if i == curtab
let group = 'airline_tabsel' let group = 'airline_tabsel'
@ -90,10 +87,7 @@ function! airline#extensions#tabline#tabs#get()
call b.add_section_spaced(group, '%(%{airline#extensions#tabline#get_buffer_name('.nr.')}%)') call b.add_section_spaced(group, '%(%{airline#extensions#tabline#get_buffer_name('.nr.')}%)')
endfor endfor
endif endif
if get(g:, 'airline#extensions#tabline#show_tab_type', 1) == 1 call airline#extensions#tabline#add_label(b, 'tabs')
call b.add_section_spaced('airline_tab',
\ get(g:, 'airline#extensions#tabline#tabs_label', '[tabs]'))
endif
let s:current_bufnr = curbuf let s:current_bufnr = curbuf
let s:current_tabnr = curtab let s:current_tabnr = curtab