motiejus/dotfiles

Unnamed repository; edit this file 'description' to name the repository.
git clone https://git.jakstys.lt/motiejus/dotfiles.git
Log | Tree | Refs | README | LICENSE

commit a27c0fc633efcd2b294c07e09f2565df258f83e8 (tree)
parent 315eb92abdda32912c0e6c49e2d6472917584df0
Author: Tim Pope <code@tpope.net>
Date:   Tue,  2 Feb 2010 23:46:04 -0500

Add optional statusline indicator

Diffstat:
Mdoc/fugitive.txt | 9+++++++++
Mplugin/fugitive.vim | 26++++++++++++++++++++++++++
2 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/doc/fugitive.txt b/doc/fugitive.txt @@ -195,6 +195,15 @@ HEAD^:Makefile The file named Makefile in the parent of HEAD :3 The current file in the merged branch during a conflict :/foo The most recent commit with "foo" in the message +STATUSLINE *fugitive-statusline* + + *fugitive#statusline()* +Add %{fugitive#statusline()} to your statusline to get an indicator including +the current branch and the currently edited file's commit. If you don't have +a statusline, this one matches the default when 'ruler' is set: +> + set statusline=%<%f\ %h%m%r%{fugitive#statusline()}%=%-14.(%l,%c%V%)\ %P +< ABOUT *fugitive-about* Grab the latest version or report a bug on Github: diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim @@ -1609,5 +1609,31 @@ function! s:GF(mode) abort endfunction " }}}1 +" Statusline {{{1 + +function! s:repo_head_ref() dict abort + return readfile(s:repo().dir('HEAD'))[0] +endfunction + +call s:add_methods('repo',['head_ref']) + +function! fugitive#statusline(...) + if !exists('b:git_dir') + return '' + endif + let status = 'Git' + if s:buffer().commit() != '' + let status .= ':' . s:buffer().commit()[0:7] + endif + let head = s:repo().head_ref() + if head =~# '^ref: ' + let status .= s:sub(head,'^ref: %(refs/%(heads/|remotes/|tags/)=)=','(').')' + elseif head =~# '^\x\{40\}$' + let status .= '('.head[0:7].')' + endif + return '['.status.']' +endfunction + +" }}}1 " vim:set ft=vim ts=8 sw=2 sts=2: