mirror of
https://github.com/vim-airline/vim-airline.git
synced 2025-04-08 19:35:31 +02:00
add 'g:airline#extensions#tabline#tabtitle_formatter' option
The option can be used to specify a customized format() function to display tab title in tab mode
This commit is contained in:
parent
3a55368320
commit
5d3cfa4045
@ -186,6 +186,11 @@ function! airline#extensions#tabline#title(n)
|
||||
let title = gettabvar(a:n, 'title')
|
||||
endif
|
||||
|
||||
let formatter = get(g:, 'airline#extensions#tabline#tabtitle_formatter')
|
||||
if empty(title) && formatter !=# '' && exists("*".formatter)
|
||||
let title = call(formatter, [a:n])
|
||||
endif
|
||||
|
||||
if empty(title)
|
||||
let buflist = tabpagebuflist(a:n)
|
||||
let winnr = tabpagewinnr(a:n)
|
||||
|
@ -1216,6 +1216,30 @@ Note: Not displayed if the number of tabs is less than 1
|
||||
|
||||
let g:airline#extensions#tabline#formatter = 'short_path'
|
||||
|
||||
* defines the customized format() function to display tab title in tab mode. >
|
||||
let g:airline#extensions#tabline#tabtitle_formatter = 'MyTabTitleFormatter'
|
||||
<
|
||||
Then define the MyTabTitleFormatter() function in your vimrc. >
|
||||
function MyTabTitleFormatter(n)
|
||||
let buflist = tabpagebuflist(a:n)
|
||||
let winnr = tabpagewinnr(a:n)
|
||||
let bufnr = buflist[winnr - 1]
|
||||
let winid = win_getid(winnr, a:n)
|
||||
let title = bufname(bufnr)
|
||||
|
||||
if empty(title)
|
||||
if getqflist({'qfbufnr' : 0}).qfbufnr == bufnr
|
||||
let title = '[Quickfix List]'
|
||||
elseif winid && getloclist(winid, {'qfbufnr' : 0}).qfbufnr == bufnr
|
||||
let title = '[Location List]'
|
||||
else
|
||||
let title = '[No Name]'
|
||||
endif
|
||||
endif
|
||||
|
||||
return title
|
||||
endfunction
|
||||
|
||||
* configure the minimum number of buffers needed to show the tabline. >
|
||||
let g:airline#extensions#tabline#buffer_min_count = 0
|
||||
<
|
||||
|
Loading…
x
Reference in New Issue
Block a user