Add formatter for short paths

Add new formatter that shows the file path up to the first parent directory
This commit is contained in:
Carlo Lobrano 2019-04-10 22:17:43 +02:00
parent cbf264ff5f
commit ebb8f0c2b1
1 changed files with 19 additions and 0 deletions

View File

@ -0,0 +1,19 @@
" MIT License. Copyright (c) 2013-2019 Bailey Ling et al.
" vim: et ts=2 sts=2 sw=2
scriptencoding utf-8
let s:fnamecollapse = get(g:, 'airline#extensions#tabline#fnamecollapse', 1)
function! airline#extensions#tabline#formatters#short_path#format(bufnr, buffers)
let _ = ''
let name = bufname(a:bufnr)
if empty(name)
let _ .= '[No Name]'
else
let _ .= fnamemodify(name, ':p:h:t') . '/' . fnamemodify(name, ':t')
endif
return airline#extensions#tabline#formatters#default#wrap_name(a:bufnr, _)
endfunction