Merge pull request #1578 from ompugao/tabline_collapse_fname

collapse fname in tabline when using unique_tail formatter
This commit is contained in:
Christian Brabandt 2017-11-06 08:19:04 +01:00 committed by GitHub
commit 396cc92261
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -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)

View File

@ -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'