diff --git a/autoload/airline/extensions/tabline/formatters/default.vim b/autoload/airline/extensions/tabline/formatters/default.vim index 7e369ac..db0618a 100644 --- a/autoload/airline/extensions/tabline/formatters/default.vim +++ b/autoload/airline/extensions/tabline/formatters/default.vim @@ -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, _) diff --git a/doc/airline.txt b/doc/airline.txt index 9507d04..aa77a46 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -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