From 05a9c9441bc84aa52df70e9d44ce4b3c817a50e4 Mon Sep 17 00:00:00 2001 From: Derek Wyatt Date: Tue, 25 Feb 2014 09:53:54 -0500 Subject: [PATCH] Status line trimming - Fugitive is awesome, but if I have a long branch name (which is common where I work) then it steals all of the real-estate in the status line - This change turns things like '[Git(feature/XYZ-9999_Description-goes-here)]' into something like '{f/XYZ-9999_}' - Also updated my config for the changes I made to vim-ag --- vimrc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/vimrc b/vimrc index 554174f..342ae41 100644 --- a/vimrc +++ b/vimrc @@ -65,8 +65,19 @@ set hidden " the text and replacing it set cpoptions=ces$ +function! DerekFugitiveStatusLine() + let status = fugitive#statusline() + let trimmed = substitute(status, '\[Git(\(.*\))\]', '\1', '') + let trimmed = substitute(trimmed, '\(\w\)\w\+\ze/', '\1', '') + if len(trimmed) == 0 + return "" + else + return '{' . trimmed[0:10] . '}' + endif +endfunction + " Set the status line the way i like it -set stl=%f\ %m\ %r%{fugitive#statusline()}\ Line:%l/%L[%p%%]\ Col:%v\ Buf:#%n\ [%b][0x%B] +set stl=%f\ %m\ %r%{DerekFugitiveStatusLine()}\ Line:%l/%L[%p%%]\ Col:%v\ Buf:#%n\ [%b][0x%B] " tell VIM to always put a status line in, even if there is only one window set laststatus=2 @@ -411,7 +422,7 @@ endif nmap ,sf :AgForCurrentFileDir nmap ,sr :AgForProjectRoot nmap ,se :AgForExtension -let g:ag_results_mapping = { +let g:ag_results_mapping_replacements = { \ 'open_and_close': '', \ 'open': 'o', \ }