vim:keys: Make git mappings fugitive independent
Make the git {add,stash,checkout} mappings independent of fugitive.vim.
This commit is contained in:
@@ -111,17 +111,21 @@ vnoremap # y?\V<C-R>=escape(@",'?\')<CR><CR>
|
|||||||
nnoremap <expr> gp '`[' . strpart(getregtype(), 0, 1) . '`]'
|
nnoremap <expr> gp '`[' . strpart(getregtype(), 0, 1) . '`]'
|
||||||
|
|
||||||
" Git bindings
|
" Git bindings
|
||||||
|
|
||||||
" Insert a commit's subject behind the SHA1 that the cursor is currently on.
|
" Insert a commit's subject behind the SHA1 that the cursor is currently on.
|
||||||
" Mnemonic: "git reference commit"
|
" Mnemonic: "git reference commit"
|
||||||
" NOTE: This uses `system` and not `:r!` to insert the text directly at the
|
" NOTE: This uses `system` and not `:r!` to insert the text directly at the
|
||||||
" cursor. `subject[:-2]` cuts off the trailing newline.
|
" cursor. `subject[:-2]` cuts off the trailing newline.
|
||||||
nmap <leader>grc :let subject=system('git show -s --format="(\"%s\")" <C-R><C-W>')<CR>ea <C-R>=subject[:-2]<CR><Esc>
|
nmap <leader>grc :let subject=system('git show -s --format="(\"%s\")" <C-R><C-W>')<CR>ea <C-R>=subject[:-2]<CR><Esc>
|
||||||
if exists('g:loaded_fugitive')
|
|
||||||
nmap <leader>gc :G commit<CR>
|
|
||||||
|
|
||||||
nmap <leader>ga :G add -- %<CR>
|
" Add, stash or checkout the current file
|
||||||
nmap <leader>gs :G stash -- %<CR>
|
nmap <leader>ga :!git add -- %<CR>
|
||||||
nmap <leader>gu :G checkout -- %<CR>
|
nmap <leader>gs :!git stash -- %<CR>
|
||||||
|
nmap <leader>gu :!git checkout -- %<CR>
|
||||||
|
|
||||||
|
if exists('g:loaded_fugitive')
|
||||||
|
" Using fugitive.vim, start a commit and open the message in a new split
|
||||||
|
nmap <leader>gc :G commit<CR>
|
||||||
else
|
else
|
||||||
" only works if a file is already opened
|
" only works if a file is already opened
|
||||||
nnoremap <leader>gcd :cd %:h <Bar> cd `git rev-parse --show-toplevel`<CR>
|
nnoremap <leader>gcd :cd %:h <Bar> cd `git rev-parse --show-toplevel`<CR>
|
||||||
|
|||||||
Reference in New Issue
Block a user