Skip to content

Commit

Permalink
Merge junegunn#53
Browse files Browse the repository at this point in the history
  • Loading branch information
somini committed Dec 9, 2020
2 parents 07cc8fb + 600945a commit e450550
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions plugin/gv.vim
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,11 @@ function! s:syntax()
endfunction

function! s:maps()
nnoremap <buffer> <Plug>(gv-refresh) :<c-u>call <sid>refresh()<cr>
nnoremap <silent> <buffer> q :$wincmd w <bar> close<cr>
nnoremap <silent> <buffer> <nowait> gq :$wincmd w <bar> close<cr>
nmap <silent> <buffer> r <Plug>(gv-refresh)
nnoremap <silent> <buffer> gb :call <sid>gbrowse()<cr>
nnoremap <silent> <buffer> <cr> :call <sid>open(0)<cr>
nnoremap <silent> <buffer> o :call <sid>open(0)<cr>
Expand Down Expand Up @@ -360,6 +363,13 @@ function! s:gv(bang, visual, line1, line2, args) abort
call s:list(fugitive_repo, 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
Expand All @@ -369,6 +379,19 @@ 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

function! s:gvcomplete(a, l, p) abort
return fugitive#repo().superglob(a:a)
endfunction
Expand Down

0 comments on commit e450550

Please sign in to comment.