tabline: add fnametruncate option to truncate long tab/buffer names

This commit is contained in:
Lawrence M 2015-03-20 16:37:36 -07:00
parent 5dc0cc5418
commit 252978e4ac
2 changed files with 7 additions and 0 deletions

View File

@ -3,6 +3,7 @@
let s:fmod = get(g:, 'airline#extensions#tabline#fnamemod', ':~:.')
let s:fnamecollapse = get(g:, 'airline#extensions#tabline#fnamecollapse', 1)
let s:fnametruncate = get(g:, 'airline#extensions#tabline#fnametruncate', 0)
let s:buf_nr_format = get(g:, 'airline#extensions#tabline#buffer_nr_format', '%s: ')
let s:buf_nr_show = get(g:, 'airline#extensions#tabline#buffer_nr_show', 0)
let s:buf_modified_symbol = g:airline_symbols.modified
@ -19,6 +20,9 @@ function! airline#extensions#tabline#formatters#default#format(bufnr, buffers)
else
let _ .= fnamemodify(name, s:fmod)
endif
if a:bufnr != bufnr('%') && s:fnametruncate && strlen(_) > s:fnametruncate
let _ = strpart(_, 0, s:fnametruncate)
endif
endif
return airline#extensions#tabline#formatters#default#wrap_name(a:bufnr, _)

View File

@ -489,6 +489,9 @@ exposed.
<
* configure collapsing parent directories in buffer name. >
let g:airline#extensions#tabline#fnamecollapse = 1
<
* configure truncating non-active buffer names to specified length. >
let g:airline#extensions#tabline#fnametruncate = 0
" The `unique_tail` algorithm will display the tail of the filename, unless
" there is another file of the same name, in which it will display it along