-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
extra
Junegunn Choi edited this page Jul 8, 2015
·
22 revisions
if !empty(filter(copy(g:plugs), '!isdirectory(v:val.dir)'))
autocmd VimEnter * PlugInstall | q
endif
Press gx
to open GitHub URL for the commit with the default browser. You'll need to change open
command to xdg-open
or the likes on Linux.
function! s:plug_gx()
let sha = matchstr(getline('.'), '^ \zs[0-9a-f]\{7}\ze ')
if empty(sha)
return
endif
let name = getline(search('^- .*:$', 'bn'))[2:-2]
let uri = get(g:plugs[name], 'uri', '')
if uri !~ 'github.com'
return
endif
execute printf('silent !open https://github.com/%s/commit/%s',
\ matchstr(uri, '[^:/]*/'.name), sha)
redraw!
endfunction
augroup PlugDiffGx
autocmd!
autocmd FileType vim-plug nnoremap <silent> <buffer> gx :call <sid>plug_gx()<cr>
augroup END
(suggested by @sodapopcan)
-
J
/K
to scroll the preview window -
CTRL-N
/CTRL-P
to move between the commits -
CTRL-J
/CTRL-K
to move between the commits and synchronize the preview window
function! s:scroll_preview(down)
silent! wincmd P
if &previewwindow
execute 'normal!' a:down ? "\<c-e>" : "\<c-y>"
wincmd p
endif
endfunction
function! s:setup_extra_keys()
nnoremap <silent> <buffer> J :call <sid>scroll_preview(1)<cr>
nnoremap <silent> <buffer> K :call <sid>scroll_preview(0)<cr>
nnoremap <silent> <buffer> <c-n> :call search('^ \zs[0-9a-f]')<cr>
nnoremap <silent> <buffer> <c-p> :call search('^ \zs[0-9a-f]', 'b')<cr>
nmap <silent> <buffer> <c-j> <c-n>o
nmap <silent> <buffer> <c-k> <c-p>o
endfunction
augroup PlugDiffExtra
autocmd!
autocmd FileType vim-plug call s:setup_extra_keys()
augroup END