forked from vim-airline/vim-airline
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request vim-airline#1603 from Cimbali/master
Improve fugitive integration
- Loading branch information
Showing
4 changed files
with
77 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
" MIT License. Copyright (c) 2017 Cimbali. | ||
" vim: et ts=2 sts=2 sw=2 | ||
|
||
scriptencoding utf-8 | ||
|
||
if !exists('*fugitive#head') | ||
finish | ||
endif | ||
|
||
|
||
if exists("+autochdir") && &autochdir == 1 | ||
let s:fmod = ':p' | ||
else | ||
let s:fmod = ':.' | ||
endif | ||
|
||
function! airline#extensions#fugitiveline#bufname() | ||
try | ||
let buffer = fugitive#buffer() | ||
if buffer.type('blob') | ||
return fnamemodify(buffer.repo().translate(buffer.path()), s:fmod) | ||
endif | ||
catch | ||
endtry | ||
|
||
return fnamemodify(bufname('%'), s:fmod) | ||
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 | ||
endfunction | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters