2018-01-05 09:37:59 +00:00
|
|
|
" MIT License. Copyright (c) 2017-2018 Cimbali et al
|
2017-11-22 21:11:58 +00:00
|
|
|
" vim: et ts=2 sts=2 sw=2
|
|
|
|
|
|
|
|
scriptencoding utf-8
|
|
|
|
|
2018-06-04 15:31:13 +00:00
|
|
|
if !airline#util#has_fugitive()
|
2017-11-22 21:11:58 +00:00
|
|
|
finish
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
if exists("+autochdir") && &autochdir == 1
|
|
|
|
let s:fmod = ':p'
|
|
|
|
else
|
|
|
|
let s:fmod = ':.'
|
|
|
|
endif
|
|
|
|
|
|
|
|
function! airline#extensions#fugitiveline#bufname()
|
2018-01-09 19:07:54 +00:00
|
|
|
if !exists('b:fugitive_name')
|
|
|
|
let b:fugitive_name = ''
|
|
|
|
try
|
|
|
|
let buffer = fugitive#buffer()
|
|
|
|
if buffer.type('blob')
|
2018-06-27 22:03:34 +00:00
|
|
|
let b:fugitive_name = buffer.repo().translate(buffer.path('/'))
|
2018-01-09 19:07:54 +00:00
|
|
|
endif
|
|
|
|
catch
|
|
|
|
endtry
|
2017-12-23 14:18:39 +00:00
|
|
|
endif
|
|
|
|
|
2018-01-09 19:07:54 +00:00
|
|
|
if empty(b:fugitive_name)
|
|
|
|
return fnamemodify(bufname('%'), s:fmod)
|
|
|
|
else
|
|
|
|
return fnamemodify(b:fugitive_name, s:fmod)
|
|
|
|
endif
|
2017-11-22 21:11:58 +00:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! airline#extensions#fugitiveline#init(ext)
|
|
|
|
if exists("+autochdir") && &autochdir == 1
|
|
|
|
" if 'acd' is set, vim-airline uses the path section, so we need to redefine this here as well
|
|
|
|
call airline#parts#define_raw('path', '%<%{airline#extensions#fugitiveline#bufname()}%m')
|
|
|
|
else
|
|
|
|
call airline#parts#define_raw('file', '%<%{airline#extensions#fugitiveline#bufname()}%m')
|
|
|
|
endif
|
2017-12-23 14:18:39 +00:00
|
|
|
autocmd ShellCmdPost,CmdwinLeave * unlet! b:fugitive_name
|
|
|
|
autocmd User AirlineBeforeRefresh unlet! b:fugitive_name
|
2017-11-22 21:11:58 +00:00
|
|
|
endfunction
|