From ebb8f0c2b1106b71ed44043bec2fc63b6e171b63 Mon Sep 17 00:00:00 2001 From: Carlo Lobrano Date: Wed, 10 Apr 2019 22:17:43 +0200 Subject: [PATCH 1/2] Add formatter for short paths Add new formatter that shows the file path up to the first parent directory --- .../tabline/formatters/short_path.vim | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 autoload/airline/extensions/tabline/formatters/short_path.vim diff --git a/autoload/airline/extensions/tabline/formatters/short_path.vim b/autoload/airline/extensions/tabline/formatters/short_path.vim new file mode 100644 index 00000000..cb4897df --- /dev/null +++ b/autoload/airline/extensions/tabline/formatters/short_path.vim @@ -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 From 0f1aec97daea2a03c54cca89d48bd9969ebcc648 Mon Sep 17 00:00:00 2001 From: Carlo Lobrano Date: Sun, 14 Apr 2019 10:03:24 +0200 Subject: [PATCH 2/2] Add documentation for short_path formatter --- doc/airline.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/airline.txt b/doc/airline.txt index 44dac5c7..2beb2d4c 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -976,7 +976,15 @@ with the middle mouse button to delete that buffer. " The `unique_tail_improved` - another algorithm, that will smartly uniquify " buffers names with similar filename, suppressing common parts of paths. let g:airline#extensions#tabline#formatter = 'unique_tail_improved' -< + + " The `short_path` - is a simple formatter, that will show the + filename, with its extension, and the first parent directory only. + + e.g. + /home/user/project/subdir/file.ext -> subdir/file.ext + + let g:airline#extensions#tabline#formatter = 'short_path' + * configure the minimum number of buffers needed to show the tabline. > let g:airline#extensions#tabline#buffer_min_count = 0 <