-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PlugDiff mappings #255
PlugDiff mappings #255
Conversation
Thanks, looks useful. I'll review the code later in the day. Can you write test cases for these? |
By the way, the same idea can be implemented without touching the core. This approach can be considered to be more flexible as it allows users to choose whatever keys (or behaviors) they want. (e.g. 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>
" We can even do this
nmap <silent> <buffer> <c-j> <c-n>o
nmap <silent> <buffer> <c-k> <c-p>o
endfunction
autocmd! FileType vim-plug call s:setup_extra_keys() |
That's a lot more elegant than mine 👍 I know I'm doing a bit much with the I chose So you're just saying to use this in my vimrc? If you don't want to include it, is it cool to at least make the preview window The other thing I was thinking In any event, thanks for the attention to this! I know I'm talking a lot about a small feature, but And yes, I can write tests for anything you are willing to accept! |
+1 to |
I'm fine with all that. Thank you, sir! |
Thanks, could you update the PR to have only |
fc74c53
to
6286337
Compare
Done. Thanks a lot! |
Make commit preview unmodifiable + map q for quit
Merged, thanks! I'll create a wiki page and let you know. |
So here's the page: https://github.com/junegunn/vim-plug/wiki/extra You can freely update or add examples. Thanks. |
Awesome, thanks for the credit :)
|
FYI, I just realized that making the buffer |
Oh crap, I never tried that. I only tried opening different commits. My On Wed, Jul 8, 2015 at 12:27 PM, Junegunn Choi notifications@github.com
|
No problem! |
Hoping you will be interested in this (obviously) and maybe try it out a bit (I've only been using it for a day).
This introduces some new mappings for
:PlugDiff
:J
andK
can be used from the diff buffer to scroll the commit preview window without having to switch to it.<C-N>
and<C-P>
can be used to jump straight to commit lines (sorta like jumping to files in fugitive's commit window).I've also made the commit window
unmodifiable
and mappedq
to:quit
(while inside it).This PR introduces a
s:buffocus()
utility function. This is used to ensure that theJ
andK
mappings will only ever scroll the commit preview window. If you would like me to ditch it in favour ofwincmd p
--or just change its location in the file--I will oblige.I've also documented the
<CR>
ando
mappings for:PlugDiff
.If you're willing to accept this PR, I'm happy to make any other changes or edits but otherwise, thanks for this amazing plugin manager.