vim-merginal
vim-merginal copied to clipboard
Map <CR> to checkout the branch under cursor
It seems to me that the most intuitive action one needs to do with the Merginal is to switch branches. Is it just my stupidity that I cannot find it in documentation, or CR is really not mapped to call b:merginal.checkoutBranch()<CR>? Shouldn't it be so?
<Cr> is not mapped to anything in the Merginal buffer. I can see your point about it being the most intuitive, but I'm kind of worried about mapping <Cr> to something that modifies the files on the disk.
In the files diff buffers <Cr> is mapped to open the file under the cursor, but that action is easily reversible with <C-o>. Checking out a branch is not trivially reversible, so I find it too dangerous a command to be mapped to <Cr>.
Well, git checkout <branch> (without -f) fails if any changes in the working tree (or even index) would be destroyed by it. I guess, that command was meant to be safe for this.
@mcepl I wanted the same feature. I forked vim-merginal, added support for filetypes, and then mapped Enter to checkout a branch when in a merginal buffer.
See:
[1] https://github.com/idanarye/vim-merginal/pull/51/files#diff-807cda537f794aae62e7cc4b5ef98837dc9f780c2f3bb1aa1083cbb071aa9642R135 [2] https://github.com/tecfu/.vim/blob/develop/plugins.vim#L269-L271
@idanarye Thanks for your awesome plugin
@mcepl This issue is now resolved after most recent merge to master. See here for implementation how-to.