From f259fd5d6dfcae66264a0649dd757bce6c4ad148 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Mon, 18 Feb 2019 17:20:52 -0500 Subject: [PATCH] Provide "i" This is a weird one, and might get axed. --- autoload/fugitive.vim | 21 +++++++++++++++++++-- doc/fugitive.txt | 5 +++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 0e6cedb..7602cff 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -1553,8 +1553,8 @@ function! fugitive#BufReadStatus() abort exe "nnoremap " nowait "u :execute Do('Unstage',0)" exe "xnoremap " nowait "u :execute Do('Unstage',1)" nnoremap C :Gcommit:echohl WarningMsgecho ':Gstatus C is deprecated in favor of cc'echohl NONE - nnoremap a :execute StageInline('toggle',line('.'),v:count) - nnoremap i :execute StageInline('toggle',line('.'),v:count) + nnoremap a :execute StatusDo('Toggle',0) + nnoremap i :execute StageIntend(v:count1) exe 'nnoremap ' nowait "= :execute StageInline('toggle',line('.'),v:count)" exe 'nnoremap ' nowait "< :execute StageInline('show', line('.'),v:count)" exe 'nnoremap ' nowait "> :execute StageInline('hide', line('.'),v:count)" @@ -2359,6 +2359,23 @@ function! s:StageInline(mode, ...) abort return lnum endfunction +function! s:StageIntend(count) abort + for i in range(a:count) + if getline('.')[0:1] ==# '? ' + call s:TreeChomp('add', '--intent-to-add', '--', s:Tree() . '/' . getline('.')[2:-1]) + - + exe s:ReloadStatus() + elseif getline('.') =~# '^Unstaged' + call s:TreeChomp('add', '--intent-to-add', '--', s:Tree()) + exe s:ReloadStatus() + else + call s:StageInline('show', line('.'), 1) + endif + call s:StageNext(1) + endfor + return '.' +endfunction + function! s:StageDiff(diff) abort let lnum = line('.') let info = s:StageInfo(lnum) diff --git a/doc/fugitive.txt b/doc/fugitive.txt index a2dc853..3ccdd1e 100644 --- a/doc/fugitive.txt +++ b/doc/fugitive.txt @@ -273,6 +273,11 @@ X Discard the change under the cursor. This uses *fugitive_>* > Remove the inline diff of the file under the cursor. + *fugitive_i* +i On untracked files, call |:Git| add --intent-to-add. + Otherwise, move to next hunk, expanding inline diffs + automatically. + *fugitive_dd* dd Perform a |:Gdiff| on the file under the cursor.