# HG changeset patch # User Meredith Howard # Date 1574455417 21600 # Node ID 81ede74938904a729b01baf623984095382e2e62 # Parent 02630cc4d64a77ff5bd9ef53954c9224842323f6 improve tig diff --git a/.vim/autoload/tig.vim b/.vim/autoload/tig.vim new file mode 100644 --- /dev/null +++ b/.vim/autoload/tig.vim @@ -0,0 +1,18 @@ +" Why this wrapper? vim :term sets $TERM to xterm but supports -256color and +" all the suggestions for fixing that involve changing $TERM for vim itself +" rather than just the subprocess. Also since this runs in place we can +" switch back after. +func! tig#Tig(...) abort + call term_start( + \ ['/usr/bin/env', 'TERM=xterm-256color', 'tig'] + a:000, + \ {'curwin': 1, 'term_name': join(['!tig'] + a:000, ' '), 'exit_cb': 'tig#TigExit'} + \ ) +endfunc + +func! tig#TigBlame() abort + call tig#Tig('blame', '+' . line('.'), '--', expand('%')) +endfunc + +func! tig#TigExit(...) abort + buffer # +endfunc diff --git a/.vimrc b/.vimrc --- a/.vimrc +++ b/.vimrc @@ -128,10 +128,8 @@ command! SyntaxCompleteOn setl omnifunc= command! Mksession execute "mksession! " . v:this_session -command! TigBlame term ++curwin tig blame -- % -command! Tig term ++curwin tig -command! TigLog term ++curwin tig log -command! TigLogThis term ++curwin tig log -- % +command! -nargs=+ -complete=file Tig call tig#Tig() +command! TigBlame call tig#TigBlame() command! -nargs=+ -complete=file -bar Ag call vimrc#Ag() CAlias Rg Ag