Check if ]C and [C are already mapped

Fixes #264
This commit is contained in:
Marco Hinz 2018-08-01 22:15:18 +02:00
parent cc2b17d462
commit e94764e40c
No known key found for this signature in database
GPG Key ID: 1C980A1B657B4A4F
2 changed files with 15 additions and 5 deletions

View File

@ -512,7 +512,13 @@ Hunk jumping:~
]C Jump to last hunk.
[C Jump to first hunk.
If you don't like these mappings, you can map them yourself:
These keys only get mapped by default when:
- The keys are not mapped already (by you or another plugin).
- There are no other keys that are mapped to do the same (to avoid duplicate
mappings).
Mapping other keys:
>
nmap <leader>gj <plug>(signify-next-hunk)
nmap <leader>gk <plug>(signify-prev-hunk)

View File

@ -85,13 +85,17 @@ nnoremap <silent> <expr> <plug>(signify-prev-hunk) &diff
\ ? '[c'
\ : ":\<c-u>call sy#jump#prev_hunk(v:count1)\<cr>"
if empty(maparg(']c', 'n'))
if empty(maparg(']c', 'n')) && !hasmapto('<plug>(signify-next-hunk)', 'n')
nmap ]c <plug>(signify-next-hunk)
nmap ]C 9999]c
if empty(maparg(']C', 'n')) && !hasmapto('9999]c', 'n')
nmap ]C 9999]c
endif
endif
if empty(maparg('[c', 'n'))
if empty(maparg('[c', 'n')) && !hasmapto('<plug>(signify-prev-hunk)', 'n')
nmap [c <plug>(signify-prev-hunk)
nmap [C 9999[c
if empty(maparg('[C', 'n')) && !hasmapto('9999[c', 'n')
nmap [C 9999[c
end
endif
" hunk text object