diff --git a/autoload/airline/extensions/tabline/formatters/unique_tail.vim b/autoload/airline/extensions/tabline/formatters/unique_tail.vim index d9c7d6ac..9bf8fdf3 100644 --- a/autoload/airline/extensions/tabline/formatters/unique_tail.vim +++ b/autoload/airline/extensions/tabline/formatters/unique_tail.vim @@ -21,8 +21,14 @@ function! airline#extensions#tabline#formatters#unique_tail#format(bufnr, buffer endif endfor + let fmod = get(g:, 'airline#extensions#tabline#fnamemod', ':p:.') for nr in values(duplicates) - let map[nr] = airline#extensions#tabline#formatters#default#wrap_name(nr, fnamemodify(bufname(nr), ':p:.')) + let fnamecollapse = get(g:, 'airline#extensions#tabline#fnamecollapse', 1) + if fnamecollapse + let map[nr] = airline#extensions#tabline#formatters#default#wrap_name(nr, substitute(fnamemodify(name, fmod), '\v\w\zs.{-}\ze(\\|/)', '', 'g')) + else + let map[nr] = airline#extensions#tabline#formatters#default#wrap_name(nr, fnamemodify(bufname(nr), fmod)) + endif endfor if has_key(map, a:bufnr) diff --git a/doc/airline.txt b/doc/airline.txt index 18636292..178537c2 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -741,7 +741,7 @@ with the middle mouse button to delete that buffer. let g:airline#extensions#tabline#formatter = 'foo' < - Note: the following variables are only used by the 'default' formatter. + Note: the following variables are used by the 'default' formatter. When no disambiguation is needed, both 'unique_tail_improved' and 'unique_tail' delegate formatting to 'default', so these variables also control rendering of unique filenames when using these formatters. @@ -766,6 +766,12 @@ with the middle mouse button to delete that buffer. " with the containing parent directory. let g:airline#extensions#tabline#formatter = 'unique_tail' + " The following variables are also used by `unique_tail` formatter. + " the meanings are the same as the ones in default formatter. + + let g:airline#extensions#tabline#fnamemod = ':p:.' + let g:airline#extensions#tabline#fnamecollapse = 1 + " The `unique_tail_improved` - another algorithm, that will smartly uniquify " buffers names with similar filename, suppressing common parts of paths. let g:airline#extensions#tabline#formatter = 'unique_tail_improved'