2018-01-05 04:37:59 -05:00
|
|
|
" MIT License. Copyright (c) 2013-2018 Bailey Ling et al.
|
2013-12-23 00:41:24 -05:00
|
|
|
" vim: et ts=2 sts=2 sw=2
|
|
|
|
|
2016-09-23 20:16:30 -04:00
|
|
|
scriptencoding utf-8
|
|
|
|
|
2013-12-23 00:41:24 -05:00
|
|
|
let s:fnamecollapse = get(g:, 'airline#extensions#tabline#fnamecollapse', 1)
|
2015-03-20 19:37:36 -04:00
|
|
|
let s:fnametruncate = get(g:, 'airline#extensions#tabline#fnametruncate', 0)
|
2013-12-23 00:41:24 -05:00
|
|
|
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
|
|
|
|
|
2015-02-13 18:58:54 -05:00
|
|
|
function! airline#extensions#tabline#formatters#default#format(bufnr, buffers)
|
2016-12-01 08:54:07 -05:00
|
|
|
let fmod = get(g:, 'airline#extensions#tabline#fnamemod', ':~:.')
|
2013-12-23 00:41:24 -05:00
|
|
|
let _ = ''
|
|
|
|
|
|
|
|
let name = bufname(a:bufnr)
|
|
|
|
if empty(name)
|
|
|
|
let _ .= '[No Name]'
|
|
|
|
else
|
|
|
|
if s:fnamecollapse
|
2018-06-04 15:59:16 -04:00
|
|
|
" Does not handle non-ascii characters like Cyrillic: 'D/Учёба/t.c'
|
|
|
|
"let _ .= substitute(fnamemodify(name, fmod), '\v\w\zs.{-}\ze(\\|/)', '', 'g')
|
|
|
|
let _ .= pathshorten(fnamemodify(name, fmod))
|
2013-12-23 00:41:24 -05:00
|
|
|
else
|
2016-12-01 08:54:07 -05:00
|
|
|
let _ .= fnamemodify(name, fmod)
|
2013-12-23 00:41:24 -05:00
|
|
|
endif
|
2015-03-20 19:37:36 -04:00
|
|
|
if a:bufnr != bufnr('%') && s:fnametruncate && strlen(_) > s:fnametruncate
|
|
|
|
let _ = strpart(_, 0, s:fnametruncate)
|
|
|
|
endif
|
2013-12-23 00:41:24 -05:00
|
|
|
endif
|
|
|
|
|
2015-02-13 18:58:54 -05:00
|
|
|
return airline#extensions#tabline#formatters#default#wrap_name(a:bufnr, _)
|
2013-12-23 00:41:24 -05:00
|
|
|
endfunction
|
|
|
|
|
2015-02-13 18:58:54 -05:00
|
|
|
function! airline#extensions#tabline#formatters#default#wrap_name(bufnr, buffer_name)
|
2013-12-23 00:41:24 -05:00
|
|
|
let _ = s:buf_nr_show ? printf(s:buf_nr_format, a:bufnr) : ''
|
|
|
|
let _ .= substitute(a:buffer_name, '\\', '/', 'g')
|
|
|
|
|
|
|
|
if getbufvar(a:bufnr, '&modified') == 1
|
|
|
|
let _ .= s:buf_modified_symbol
|
|
|
|
endif
|
|
|
|
return _
|
|
|
|
endfunction
|