mirror of
https://github.com/vim-airline/vim-airline.git
synced 2024-11-22 09:22:53 +08:00
parent
133a76d2d4
commit
ce83c39bed
14
autoload/airline/extensions/tabline/formatters/tabnr.vim
Normal file
14
autoload/airline/extensions/tabline/formatters/tabnr.vim
Normal file
|
@ -0,0 +1,14 @@
|
|||
" MIT License. Copyright (c) 2017 C.Brabandt
|
||||
" vim: et ts=2 sts=2 sw=2
|
||||
|
||||
scriptencoding utf-8
|
||||
|
||||
function! airline#extensions#tabline#formatters#tabnr#format(tab_nr_type, nr)
|
||||
if a:tab_nr_type == 0 " nr of splits
|
||||
return (g:airline_symbols.space).'%{len(tabpagebuflist('.a:nr.'))}'
|
||||
elseif a:tab_nr_type == 1 " tab number
|
||||
return (g:airline_symbols.space).a:nr
|
||||
else "== 2 splits and tab number
|
||||
return (g:airline_symbols.space).a:nr.'.%{len(tabpagebuflist('.a:nr.'))}'
|
||||
endif
|
||||
endfunction
|
|
@ -68,13 +68,7 @@ function! airline#extensions#tabline#tabs#get()
|
|||
let val = '%('
|
||||
|
||||
if get(g:, 'airline#extensions#tabline#show_tab_nr', 1)
|
||||
if tab_nr_type == 0
|
||||
let val .= (g:airline_symbols.space).'%{len(tabpagebuflist('.i.'))}'
|
||||
elseif tab_nr_type == 1
|
||||
let val .= (g:airline_symbols.space).i
|
||||
else "== 2
|
||||
let val .= (g:airline_symbols.space).i.'.%{len(tabpagebuflist('.i.'))}'
|
||||
endif
|
||||
let val .= airline#extensions#tabline#tabs#tabnr_formatter(tab_nr_type, i)
|
||||
endif
|
||||
call b.add_section(group, val.'%'.i.'T %{airline#extensions#tabline#title('.i.')} %)')
|
||||
endfor
|
||||
|
@ -121,3 +115,8 @@ function! airline#extensions#tabline#tabs#map_keys()
|
|||
noremap <silent> <Plug>AirlineSelectNextTab :<C-U>exe repeat(':tabn\|', v:count1)<cr>
|
||||
let s:airline_tabline_map_key = 1
|
||||
endfunction
|
||||
|
||||
function! airline#extensions#tabline#tabs#tabnr_formatter(nr, i)
|
||||
let formatter = get(g:, 'airline#extensions#tabline#tabnr_formatter', 'tabnr')
|
||||
return airline#extensions#tabline#formatters#{formatter}#format(a:nr, a:i)
|
||||
endfunction
|
||||
|
|
|
@ -685,6 +685,10 @@ with the middle mouse button to delete that buffer.
|
|||
let g:airline#extensions#tabline#tab_nr_type = 0 " # of splits (default)
|
||||
let g:airline#extensions#tabline#tab_nr_type = 1 " tab number
|
||||
let g:airline#extensions#tabline#tab_nr_type = 2 " splits and tab number
|
||||
let g:airline#extensions#tabline#tabnr_formatter = 'tabnr'
|
||||
|
||||
Note: last option can be used to specify a different formatter for
|
||||
displaying the numbers. By default tabline/formatter/tabnr.vim is used
|
||||
<
|
||||
* enable/disable displaying tab number in tabs mode. >
|
||||
let g:airline#extensions#tabline#show_tab_nr = 1
|
||||
|
|
Loading…
Reference in New Issue
Block a user