2018-01-05 17:37:59 +08:00
|
|
|
" MIT License. Copyright (c) 2013-2018 Bailey Ling et al.
|
2013-12-23 13:41:24 +08:00
|
|
|
" vim: et ts=2 sts=2 sw=2
|
|
|
|
|
2016-09-24 08:16:30 +08:00
|
|
|
scriptencoding utf-8
|
|
|
|
|
2013-12-23 13:41:24 +08:00
|
|
|
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)
|
2016-12-01 21:54:07 +08:00
|
|
|
let fmod = get(g:, 'airline#extensions#tabline#fnamemod', ':~:.')
|
2013-12-23 13:41:24 +08:00
|
|
|
let _ = ''
|
|
|
|
|
|
|
|
let name = bufname(a:bufnr)
|
|
|
|
if empty(name)
|
|
|
|
let _ .= '[No Name]'
|
|
|
|
else
|
|
|
|
if s:fnamecollapse
|
2016-12-01 21:54:07 +08:00
|
|
|
let _ .= substitute(fnamemodify(name, fmod), '\v\w\zs.{-}\ze(\\|/)', '', 'g')
|
2013-12-23 13:41:24 +08:00
|
|
|
else
|
2016-12-01 21:54:07 +08:00
|
|
|
let _ .= fnamemodify(name, fmod)
|
2013-12-23 13:41:24 +08:00
|
|
|
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
|