From dbd9121c055f90aa8bdec3a46877078c9c3c2728 Mon Sep 17 00:00:00 2001 From: Bailey Ling Date: Sat, 7 Sep 2013 15:09:19 +0000 Subject: [PATCH] allow collapsing to be configurable. also fix win paths. --- autoload/airline/extensions/tabline/formatters.vim | 7 ++++++- doc/airline.txt | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/autoload/airline/extensions/tabline/formatters.vim b/autoload/airline/extensions/tabline/formatters.vim index 9a0fa8f..749c60d 100644 --- a/autoload/airline/extensions/tabline/formatters.vim +++ b/autoload/airline/extensions/tabline/formatters.vim @@ -2,6 +2,7 @@ " vim: et ts=2 sts=2 sw=2 let s:fmod = get(g:, 'airline#extensions#tabline#fnamemod', ':p:.') +let s:fnamecollapse = get(g:, 'airline#extensions#tabline#fnamecollapse', 1) 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 @@ -17,7 +18,11 @@ function! airline#extensions#tabline#formatters#default(bufnr, buffers) if empty(name) let _ .= '[No Name]' else - let _ .= substitute(fnamemodify(name, s:fmod), '\w\zs.\{-}\ze\/', '', 'g') + if s:fnamecollapse + let _ .= substitute(fnamemodify(name, s:fmod), '\v\w\zs.{-}\ze(\\|/)', '', 'g') + else + let _ .= fnamemodify(name, s:fmod) + endif endif if getbufvar(a:bufnr, '&modified') == 1 diff --git a/doc/airline.txt b/doc/airline.txt index 14c6d04..b203b85 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -331,6 +331,9 @@ virtualenv < * configure the formatting of filenames (see |filename-modifiers|). > let g:airline#extensions#tabline#fnamemod = ':p:.' +< + * configure collapsing parent directories in buffer name. > + let g:airline#extensions#tabline#fnamecollapse = 1 < * configure the minimum number of buffers needed to show the tabline. > let g:airline#extensions#tabline#buffer_min_count = 0