Deprecate <Plug>... maps in favour of <Plug>(...)

This commit is contained in:
Andy Stewart
2019-09-04 08:56:36 +01:00
parent 43c82ce8fb
commit 0469b8435a
5 changed files with 57 additions and 51 deletions

View File

@@ -180,8 +180,8 @@ Both of those take a preceding count.
To set your own mappings for these, for example `]h` and `[h`: To set your own mappings for these, for example `]h` and `[h`:
```viml ```viml
nmap ]h <Plug>GitGutterNextHunk nmap ]h <Plug>(GitGutterNextHunk)
nmap [h <Plug>GitGutterPrevHunk nmap [h <Plug>(GitGutterPrevHunk)
``` ```
You can load all your hunks into the quickfix list with `:GitGutterQuickFix`. Note this ignores any unsaved changes in your buffers. You can load all your hunks into the quickfix list with `:GitGutterQuickFix`. Note this ignores any unsaved changes in your buffers.
@@ -212,14 +212,14 @@ The `.` command will work with both these if you install [repeat.vim](https://gi
To set your own mappings for these, for example if you prefer the mnemonics hunk-add and hunk-revert: To set your own mappings for these, for example if you prefer the mnemonics hunk-add and hunk-revert:
```viml ```viml
nmap <Leader>ha <Plug>GitGutterStageHunk nmap <Leader>ha <Plug>(GitGutterStageHunk)
nmap <Leader>hr <Plug>GitGutterUndoHunk nmap <Leader>hr <Plug>(GitGutterUndoHunk)
``` ```
And you can preview a hunk's changes with `<Leader>hp`. The location of the preview window is configured with `g:gitgutter_preview_win_location` (default `'bo'`). You can of course change this mapping, e.g: And you can preview a hunk's changes with `<Leader>hp`. The location of the preview window is configured with `g:gitgutter_preview_win_location` (default `'bo'`). You can of course change this mapping, e.g:
```viml ```viml
nmap <Leader>hv <Plug>GitGutterPreviewHunk nmap <Leader>hv <Plug>(GitGutterPreviewHunk)
``` ```
A hunk text object is provided which works in visual and operator-pending modes. A hunk text object is provided which works in visual and operator-pending modes.
@@ -230,10 +230,10 @@ A hunk text object is provided which works in visual and operator-pending modes.
To re-map these, for example to `ih` and `ah`: To re-map these, for example to `ih` and `ah`:
```viml ```viml
omap ih <Plug>GitGutterTextObjectInnerPending omap ih <Plug>(GitGutterTextObjectInnerPending)
omap ah <Plug>GitGutterTextObjectOuterPending omap ah <Plug>(GitGutterTextObjectOuterPending)
xmap ih <Plug>GitGutterTextObjectInnerVisual xmap ih <Plug>(GitGutterTextObjectInnerVisual)
xmap ah <Plug>GitGutterTextObjectOuterVisual xmap ah <Plug>(GitGutterTextObjectOuterVisual)
``` ```
If you don't want vim-gitgutter to set up any mappings at all, use this: If you don't want vim-gitgutter to set up any mappings at all, use this:

View File

@@ -119,37 +119,37 @@ function! gitgutter#setup_maps()
return return
endif endif
if !hasmapto('<Plug>GitGutterPrevHunk') && maparg('[c', 'n') ==# '' if !hasmapto('<Plug>(GitGutterPrevHunk)') && maparg('[c', 'n') ==# ''
nmap <buffer> [c <Plug>GitGutterPrevHunk nmap <buffer> [c <Plug>(GitGutterPrevHunk)
endif endif
if !hasmapto('<Plug>GitGutterNextHunk') && maparg(']c', 'n') ==# '' if !hasmapto('<Plug>(GitGutterNextHunk)') && maparg(']c', 'n') ==# ''
nmap <buffer> ]c <Plug>GitGutterNextHunk nmap <buffer> ]c <Plug>(GitGutterNextHunk)
endif endif
if !hasmapto('<Plug>GitGutterStageHunk', 'v') && maparg('<Leader>hs', 'x') ==# '' if !hasmapto('<Plug>(GitGutterStageHunk)', 'v') && maparg('<Leader>hs', 'x') ==# ''
xmap <buffer> <Leader>hs <Plug>GitGutterStageHunk xmap <buffer> <Leader>hs <Plug>(GitGutterStageHunk)
endif endif
if !hasmapto('<Plug>GitGutterStageHunk', 'n') && maparg('<Leader>hs', 'n') ==# '' if !hasmapto('<Plug>(GitGutterStageHunk)', 'n') && maparg('<Leader>hs', 'n') ==# ''
nmap <buffer> <Leader>hs <Plug>GitGutterStageHunk nmap <buffer> <Leader>hs <Plug>(GitGutterStageHunk)
endif endif
if !hasmapto('<Plug>GitGutterUndoHunk') && maparg('<Leader>hu', 'n') ==# '' if !hasmapto('<Plug>(GitGutterUndoHunk)') && maparg('<Leader>hu', 'n') ==# ''
nmap <buffer> <Leader>hu <Plug>GitGutterUndoHunk nmap <buffer> <Leader>hu <Plug>(GitGutterUndoHunk)
endif endif
if !hasmapto('<Plug>GitGutterPreviewHunk') && maparg('<Leader>hp', 'n') ==# '' if !hasmapto('<Plug>(GitGutterPreviewHunk)') && maparg('<Leader>hp', 'n') ==# ''
nmap <buffer> <Leader>hp <Plug>GitGutterPreviewHunk nmap <buffer> <Leader>hp <Plug>(GitGutterPreviewHunk)
endif endif
if !hasmapto('<Plug>GitGutterTextObjectInnerPending') && maparg('ic', 'o') ==# '' if !hasmapto('<Plug>(GitGutterTextObjectInnerPending)') && maparg('ic', 'o') ==# ''
omap <buffer> ic <Plug>GitGutterTextObjectInnerPending omap <buffer> ic <Plug>(GitGutterTextObjectInnerPending)
endif endif
if !hasmapto('<Plug>GitGutterTextObjectOuterPending') && maparg('ac', 'o') ==# '' if !hasmapto('<Plug>(GitGutterTextObjectOuterPending)') && maparg('ac', 'o') ==# ''
omap <buffer> ac <Plug>GitGutterTextObjectOuterPending omap <buffer> ac <Plug>(GitGutterTextObjectOuterPending)
endif endif
if !hasmapto('<Plug>GitGutterTextObjectInnerVisual') && maparg('ic', 'x') ==# '' if !hasmapto('<Plug>(GitGutterTextObjectInnerVisual)') && maparg('ic', 'x') ==# ''
xmap <buffer> ic <Plug>GitGutterTextObjectInnerVisual xmap <buffer> ic <Plug>(GitGutterTextObjectInnerVisual)
endif endif
if !hasmapto('<Plug>GitGutterTextObjectOuterVisual') && maparg('ac', 'x') ==# '' if !hasmapto('<Plug>(GitGutterTextObjectOuterVisual)') && maparg('ac', 'x') ==# ''
xmap <buffer> ac <Plug>GitGutterTextObjectOuterVisual xmap <buffer> ac <Plug>(GitGutterTextObjectOuterVisual)
endif endif
call gitgutter#utility#setbufvar(bufnr, 'mapped', 1) call gitgutter#utility#setbufvar(bufnr, 'mapped', 1)

View File

@@ -177,17 +177,17 @@ function! gitgutter#hunk#stage(...) abort
else else
call s:hunk_op(function('s:stage')) call s:hunk_op(function('s:stage'))
endif endif
silent! call repeat#set("\<Plug>GitGutterStageHunk", -1) silent! call repeat#set("\<Plug>(GitGutterStageHunk)", -1)
endfunction endfunction
function! gitgutter#hunk#undo() abort function! gitgutter#hunk#undo() abort
call s:hunk_op(function('s:undo')) call s:hunk_op(function('s:undo'))
silent! call repeat#set("\<Plug>GitGutterUndoHunk", -1) silent! call repeat#set("\<Plug>(GitGutterUndoHunk)", -1)
endfunction endfunction
function! gitgutter#hunk#preview() abort function! gitgutter#hunk#preview() abort
call s:hunk_op(function('s:preview')) call s:hunk_op(function('s:preview'))
silent! call repeat#set("\<Plug>GitGutterPreviewHunk", -1) silent! call repeat#set("\<Plug>(GitGutterPreviewHunk)", -1)
endfunction endfunction

View File

@@ -232,9 +232,9 @@ These can be repeated with `.` if you have vim-repeat installed.
You can change these mappings like this: You can change these mappings like this:
> >
nmap ghp <Plug>GitGutterPreviewHunk nmap ghp <Plug>(GitGutterPreviewHunk)
nmap ghs <Plug>GitGutterStageHunk nmap ghs <Plug>(GitGutterStageHunk)
nmap ghu <Plug>GitGutterUndoHunk nmap ghu <Plug>(GitGutterUndoHunk)
< <
Hunk jumping:~ Hunk jumping:~
@@ -247,8 +247,8 @@ Hunk jumping:~
You can change these mappings like this: You can change these mappings like this:
> >
nmap [c <Plug>GitGutterPrevHunk nmap [c <Plug>(GitGutterPrevHunk)
nmap ]c <Plug>GitGutterNextHunk nmap ]c <Plug>(GitGutterNextHunk)
< <
Hunk text object:~ Hunk text object:~
@@ -257,10 +257,10 @@ Hunk text object:~
"ic" operates on the current hunk's lines. "ac" does the same but also includes "ic" operates on the current hunk's lines. "ac" does the same but also includes
trailing empty lines. trailing empty lines.
> >
omap ic <Plug>GitGutterTextObjectInnerPending omap ic <Plug>(GitGutterTextObjectInnerPending)
omap ac <Plug>GitGutterTextObjectOuterPending omap ac <Plug>(GitGutterTextObjectOuterPending)
xmap ic <Plug>GitGutterTextObjectInnerVisual xmap ic <Plug>(GitGutterTextObjectInnerVisual)
xmap ac <Plug>GitGutterTextObjectOuterVisual xmap ac <Plug>(GitGutterTextObjectOuterVisual)
< <

View File

@@ -145,10 +145,10 @@ command! -bar GitGutterUndoHunk call gitgutter#hunk#undo()
command! -bar GitGutterPreviewHunk call gitgutter#hunk#preview() command! -bar GitGutterPreviewHunk call gitgutter#hunk#preview()
" Hunk text object " Hunk text object
onoremap <silent> <Plug>GitGutterTextObjectInnerPending :<C-U>call gitgutter#hunk#text_object(1)<CR> onoremap <silent> <Plug>(GitGutterTextObjectInnerPending) :<C-U>call gitgutter#hunk#text_object(1)<CR>
onoremap <silent> <Plug>GitGutterTextObjectOuterPending :<C-U>call gitgutter#hunk#text_object(0)<CR> onoremap <silent> <Plug>(GitGutterTextObjectOuterPending) :<C-U>call gitgutter#hunk#text_object(0)<CR>
xnoremap <silent> <Plug>GitGutterTextObjectInnerVisual :<C-U>call gitgutter#hunk#text_object(1)<CR> xnoremap <silent> <Plug>(GitGutterTextObjectInnerVisual) :<C-U>call gitgutter#hunk#text_object(1)<CR>
xnoremap <silent> <Plug>GitGutterTextObjectOuterVisual :<C-U>call gitgutter#hunk#text_object(0)<CR> xnoremap <silent> <Plug>(GitGutterTextObjectOuterVisual) :<C-U>call gitgutter#hunk#text_object(0)<CR>
" Returns the git-diff hunks for the file or an empty list if there " Returns the git-diff hunks for the file or an empty list if there
@@ -192,13 +192,19 @@ command! -bar GitGutterDebug call gitgutter#debug#debug()
" Maps {{{ " Maps {{{
nnoremap <silent> <expr> <Plug>GitGutterNextHunk &diff ? ']c' : ":\<C-U>execute v:count1 . 'GitGutterNextHunk'\<CR>" nnoremap <silent> <expr> <Plug>(GitGutterNextHunk) &diff ? ']c' : ":\<C-U>execute v:count1 . 'GitGutterNextHunk'\<CR>"
nnoremap <silent> <expr> <Plug>GitGutterPrevHunk &diff ? '[c' : ":\<C-U>execute v:count1 . 'GitGutterPrevHunk'\<CR>" nnoremap <silent> <expr> <Plug>GitGutterNextHunk &diff ? ']c' : ":\<C-U>call gitgutter#utility#warn('please change your map \<lt>Plug>GitGutterNextHunk to \<lt>Plug>(GitGutterNextHunk)')\<CR>"
nnoremap <silent> <expr> <Plug>(GitGutterPrevHunk) &diff ? '[c' : ":\<C-U>execute v:count1 . 'GitGutterPrevHunk'\<CR>"
nnoremap <silent> <expr> <Plug>GitGutterPrevHunk &diff ? '[c' : ":\<C-U>call gitgutter#utility#warn('please change your map \<lt>Plug>GitGutterPrevHunk to \<lt>Plug>(GitGutterPrevHunk)')\<CR>"
xnoremap <silent> <Plug>GitGutterStageHunk :GitGutterStageHunk<CR> xnoremap <silent> <Plug>(GitGutterStageHunk) :GitGutterStageHunk<CR>
nnoremap <silent> <Plug>GitGutterStageHunk :GitGutterStageHunk<CR> xnoremap <silent> <Plug>GitGutterStageHunk :call gitgutter#utility#warn('please change your map <Plug>GitGutterStageHunk to <Plug>(GitGutterStageHunk)')<CR>
nnoremap <silent> <Plug>GitGutterUndoHunk :GitGutterUndoHunk<CR> nnoremap <silent> <Plug>(GitGutterStageHunk) :GitGutterStageHunk<CR>
nnoremap <silent> <Plug>GitGutterPreviewHunk :GitGutterPreviewHunk<CR> nnoremap <silent> <Plug>GitGutterStageHunk :call gitgutter#utility#warn('please change your map <Plug>GitGutterStageHunk to <Plug>(GitGutterStageHunk)')<CR>
nnoremap <silent> <Plug>(GitGutterUndoHunk) :GitGutterUndoHunk<CR>
nnoremap <silent> <Plug>GitGutterUndoHunk :call gitgutter#utility#warn('please change your map <Plug>GitGutterUndoHunk to <Plug>(GitGutterUndoHunk)')<CR>
nnoremap <silent> <Plug>(GitGutterPreviewHunk) :GitGutterPreviewHunk<CR>
nnoremap <silent> <Plug>GitGutterPreviewHunk :call gitgutter#utility#warn('please change your map <Plug>GitGutterPreviewHunk to <Plug>(GitGutterPreviewHunk)')<CR>
" }}} " }}}