2016-01-15 10:38:38 +08:00
|
|
|
" MIT License. Copyright (c) 2013-2016 Bailey Ling.
|
2013-12-23 13:41:24 +08:00
|
|
|
" vim: et ts=2 sts=2 sw=2
|
|
|
|
|
|
|
|
let s:fmod = get(g:, 'airline#extensions#tabline#fnamemod', ':~:.')
|
|
|
|
let s:fnamecollapse = get(g:, 'airline#extensions#tabline#fnamecollapse', 1)
|
2015-03-21 07:37:36 +08:00
|
|
|
let s:fnametruncate = get(g:, 'airline#extensions#tabline#fnametruncate', 0)
|
2013-12-23 13:41:24 +08: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-14 07:58:54 +08:00
|
|
|
function! airline#extensions#tabline#formatters#default#format(bufnr, buffers)
|
2013-12-23 13:41:24 +08:00
|
|
|
let _ = ''
|
|
|
|
|
|
|
|
let name = bufname(a:bufnr)
|
|
|
|
if empty(name)
|
|
|
|
let _ .= '[No Name]'
|
|
|
|
else
|
|
|
|
if s:fnamecollapse
|
|
|
|
let _ .= substitute(fnamemodify(name, s:fmod), '\v\w\zs.{-}\ze(\\|/)', '', 'g')
|
|
|
|
else
|
|
|
|
let _ .= fnamemodify(name, s:fmod)
|
|
|
|
endif
|
2015-03-21 07:37:36 +08:00
|
|
|
if a:bufnr != bufnr('%') && s:fnametruncate && strlen(_) > s:fnametruncate
|
|
|
|
let _ = strpart(_, 0, s:fnametruncate)
|
|
|
|
endif
|
2013-12-23 13:41:24 +08:00
|
|
|
endif
|
|
|
|
|
2015-02-14 07:58:54 +08:00
|
|
|
return airline#extensions#tabline#formatters#default#wrap_name(a:bufnr, _)
|
2013-12-23 13:41:24 +08:00
|
|
|
endfunction
|
|
|
|
|
2015-02-14 07:58:54 +08:00
|
|
|
function! airline#extensions#tabline#formatters#default#wrap_name(bufnr, buffer_name)
|
2013-12-23 13:41:24 +08: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
|