2016-01-14 21:38:38 -05:00
|
|
|
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
2013-12-23 00:41:24 -05:00
|
|
|
" vim: et ts=2 sts=2 sw=2
|
|
|
|
|
2015-02-13 18:58:54 -05:00
|
|
|
function! airline#extensions#tabline#formatters#unique_tail#format(bufnr, buffers)
|
2013-12-23 00:41:24 -05:00
|
|
|
let duplicates = {}
|
|
|
|
let tails = {}
|
|
|
|
let map = {}
|
|
|
|
for nr in a:buffers
|
|
|
|
let name = bufname(nr)
|
|
|
|
if empty(name)
|
|
|
|
let map[nr] = '[No Name]'
|
|
|
|
else
|
2015-06-04 11:14:06 -04:00
|
|
|
let tail = fnamemodify(name, ':s?/\+$??:t')
|
2013-12-23 00:41:24 -05:00
|
|
|
if has_key(tails, tail)
|
|
|
|
let duplicates[nr] = nr
|
|
|
|
endif
|
|
|
|
let tails[tail] = 1
|
2015-02-13 18:58:54 -05:00
|
|
|
let map[nr] = airline#extensions#tabline#formatters#default#wrap_name(nr, tail)
|
2013-12-23 00:41:24 -05:00
|
|
|
endif
|
|
|
|
endfor
|
|
|
|
|
|
|
|
for nr in values(duplicates)
|
2015-02-13 18:58:54 -05:00
|
|
|
let map[nr] = airline#extensions#tabline#formatters#default#wrap_name(nr, fnamemodify(bufname(nr), ':p:.'))
|
2013-12-23 00:41:24 -05:00
|
|
|
endfor
|
|
|
|
|
2015-02-26 23:08:59 -05:00
|
|
|
if has_key(map, a:bufnr)
|
|
|
|
return map[a:bufnr]
|
|
|
|
endif
|
|
|
|
|
|
|
|
" if we get here, the buffer list isn't in sync with the selected buffer yet, fall back to the default
|
|
|
|
return airline#extensions#tabline#formatters#default#format(a:bufnr, a:buffers)
|
2013-12-23 00:41:24 -05:00
|
|
|
endfunction
|