Skip to content

Commit b788cbc

Browse files
committed
Add <plug>(plug-preview) map
This allows you to override the default behavior of `o' or `<cr>' binding in PlugDiff window. e.g. " Move to preview window autocmd! FileType vim-plug nmap <buffer> o <plug>(plug-preview)<c-w>P Close #749 Close #768
1 parent cd44b03 commit b788cbc

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

plug.vim

+7-2
Original file line numberDiff line numberDiff line change
@@ -2425,8 +2425,13 @@ function! s:diff()
24252425
\ . (cnts[1] ? printf(' %d plugin(s) have pending updates.', cnts[1]) : ''))
24262426

24272427
if cnts[0] || cnts[1]
2428-
nnoremap <silent> <buffer> <cr> :silent! call <SID>preview_commit()<cr>
2429-
nnoremap <silent> <buffer> o :silent! call <SID>preview_commit()<cr>
2428+
nnoremap <silent> <buffer> <plug>(plug-preview) :silent! call <SID>preview_commit()<cr>
2429+
if empty(maparg("\<cr>", 'n'))
2430+
nmap <buffer> <cr> <plug>(plug-preview)
2431+
endif
2432+
if empty(maparg('o', 'n'))
2433+
nmap <buffer> o <plug>(plug-preview)
2434+
endif
24302435
endif
24312436
if cnts[0]
24322437
nnoremap <silent> <buffer> X :call <SID>revert()<cr>

test/workflow.vader

+9-2
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,15 @@ Execute (New commits on remote, PlugUpdate, then PlugDiff):
370370
AssertEqual 1, &previewwindow
371371
AssertEqual 'git', &filetype
372372

373-
" Back to plug window
374-
wincmd p
373+
" Close preview window
374+
pclose
375+
376+
" Open and go to preview window with a custom mapping
377+
nmap <buffer> <c-o> <plug>(plug-preview)<c-w>P
378+
execute "normal \<c-o>"
379+
AssertEqual 1, &previewwindow, 'Should be on preview window'
380+
normal q
381+
AssertEqual 0, &previewwindow, 'Should not be on preview window'
375382

376383
" ]] motion
377384
execute 'normal $]]'

0 commit comments

Comments
 (0)