Merge pull request #2611 from uridium/master

Allow to define own path for short_path formatter
This commit is contained in:
Christian Brabandt 2022-12-23 10:42:10 +01:00 committed by GitHub
commit 9e2d021fc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -6,6 +6,7 @@ scriptencoding utf-8
let s:fnamecollapse = get(g:, 'airline#extensions#tabline#fnamecollapse', 1)
function! airline#extensions#tabline#formatters#short_path#format(bufnr, buffers)
let fmod = get(g:, 'airline#extensions#tabline#fnamemod', ':p:h:t')
let _ = ''
let name = bufname(a:bufnr)
@ -15,7 +16,7 @@ function! airline#extensions#tabline#formatters#short_path#format(bufnr, buffers
" Neovim Terminal
let _ = substitute(name, '\(term:\)//.*:\(.*\)', '\1 \2', '')
else
let _ .= fnamemodify(name, ':p:h:t') . '/' . fnamemodify(name, ':t')
let _ .= fnamemodify(name, fmod) . '/' . fnamemodify(name, ':t')
endif
return airline#extensions#tabline#formatters#default#wrap_name(a:bufnr, _)

View File

@ -1321,6 +1321,13 @@ Note: Not displayed if the number of tabs is less than 1
let g:airline#extensions#tabline#formatter = 'short_path'
" `short_path` can also display file name as relative to the current
" directory, if possible
let g:airline#extensions#tabline#fnamemod = ':h'
" or display file name as relative to the home directory, if possible
let g:airline#extensions#tabline#fnamemod = ':~:h'
* defines the customized format() function to display tab title in tab mode. >
let g:airline#extensions#tabline#tabtitle_formatter = 'MyTabTitleFormatter'
<