diff --git a/README.md b/README.md index 10e97a4..1fcb202 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ selected lines. - `gb` for `:GBrowse` - `]]` and `[[` to move between commits - `.` to start command-line with `:Git [CURSOR] SHA` à la fugitive +- `r` to refresh git state - `q` or `gq` to close Customization diff --git a/plugin/gv.vim b/plugin/gv.vim index 8e91611..9de8d4b 100644 --- a/plugin/gv.vim +++ b/plugin/gv.vim @@ -126,6 +126,8 @@ function! s:dot() endfunction function! s:maps() + nnoremap (gv-refresh) :call refresh() + nnoremap q :$wincmd w close nnoremap gq :$wincmd w close nnoremap gb :call gbrowse() @@ -317,6 +319,13 @@ function! s:gv(bang, visual, line1, line2, args) abort call s:list(log_opts) call FugitiveDetect(@#) endif + let b:gv_opts = { + \ 'bang' : a:bang, + \ 'visual' : a:visual, + \ 'line1' : a:line1, + \ 'line2' : a:line2, + \ 'args' : a:args, + \ } catch return s:warn(v:exception) finally @@ -326,4 +335,17 @@ function! s:gv(bang, visual, line1, line2, args) abort endtry endfunction +function! s:refresh() abort + let lazyredraw_bak = &lazyredraw + let &lazyredraw = 1 + + let win = winsaveview() + let old_tab = tabpagenr() + call s:gv(b:gv_opts.bang, b:gv_opts.visual, b:gv_opts.line1, b:gv_opts.line2, b:gv_opts.args) + exec 'tabclose '. old_tab + call winrestview(win) + + let &lazyredraw = lazyredraw_bak +endfunction + command! -bang -nargs=* -range=0 -complete=customlist,fugitive#CompleteObject GV call s:gv(0, , , , )