Skip to content

Commit f80eed7

Browse files
authoredJun 20, 2018
Add <plug>(plug-preview) map (#769)
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 fef4e43 commit f80eed7

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
@@ -2426,8 +2426,13 @@ function! s:diff()
24262426
\ . (cnts[1] ? printf(' %d plugin(s) have pending updates.', cnts[1]) : ''))
24272427

24282428
if cnts[0] || cnts[1]
2429-
nnoremap <silent> <buffer> <cr> :silent! call <SID>preview_commit()<cr>
2430-
nnoremap <silent> <buffer> o :silent! call <SID>preview_commit()<cr>
2429+
nnoremap <silent> <buffer> <plug>(plug-preview) :silent! call <SID>preview_commit()<cr>
2430+
if empty(maparg("\<cr>", 'n'))
2431+
nmap <buffer> <cr> <plug>(plug-preview)
2432+
endif
2433+
if empty(maparg('o', 'n'))
2434+
nmap <buffer> o <plug>(plug-preview)
2435+
endif
24312436
endif
24322437
if cnts[0]
24332438
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)