diff --git a/README.mkd b/README.mkd index a7fe4a7..621e86c 100644 --- a/README.mkd +++ b/README.mkd @@ -180,8 +180,8 @@ Both of those take a preceding count. To set your own mappings for these, for example `]h` and `[h`: ```viml -nmap ]h GitGutterNextHunk -nmap [h GitGutterPrevHunk +nmap ]h (GitGutterNextHunk) +nmap [h (GitGutterPrevHunk) ``` 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: ```viml -nmap ha GitGutterStageHunk -nmap hr GitGutterUndoHunk +nmap ha (GitGutterStageHunk) +nmap hr (GitGutterUndoHunk) ``` And you can preview a hunk's changes with `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 -nmap hv GitGutterPreviewHunk +nmap hv (GitGutterPreviewHunk) ``` 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`: ```viml -omap ih GitGutterTextObjectInnerPending -omap ah GitGutterTextObjectOuterPending -xmap ih GitGutterTextObjectInnerVisual -xmap ah GitGutterTextObjectOuterVisual +omap ih (GitGutterTextObjectInnerPending) +omap ah (GitGutterTextObjectOuterPending) +xmap ih (GitGutterTextObjectInnerVisual) +xmap ah (GitGutterTextObjectOuterVisual) ``` If you don't want vim-gitgutter to set up any mappings at all, use this: diff --git a/autoload/gitgutter.vim b/autoload/gitgutter.vim index ffc0966..13f5168 100644 --- a/autoload/gitgutter.vim +++ b/autoload/gitgutter.vim @@ -119,37 +119,37 @@ function! gitgutter#setup_maps() return endif - if !hasmapto('GitGutterPrevHunk') && maparg('[c', 'n') ==# '' - nmap [c GitGutterPrevHunk + if !hasmapto('(GitGutterPrevHunk)') && maparg('[c', 'n') ==# '' + nmap [c (GitGutterPrevHunk) endif - if !hasmapto('GitGutterNextHunk') && maparg(']c', 'n') ==# '' - nmap ]c GitGutterNextHunk + if !hasmapto('(GitGutterNextHunk)') && maparg(']c', 'n') ==# '' + nmap ]c (GitGutterNextHunk) endif - if !hasmapto('GitGutterStageHunk', 'v') && maparg('hs', 'x') ==# '' - xmap hs GitGutterStageHunk + if !hasmapto('(GitGutterStageHunk)', 'v') && maparg('hs', 'x') ==# '' + xmap hs (GitGutterStageHunk) endif - if !hasmapto('GitGutterStageHunk', 'n') && maparg('hs', 'n') ==# '' - nmap hs GitGutterStageHunk + if !hasmapto('(GitGutterStageHunk)', 'n') && maparg('hs', 'n') ==# '' + nmap hs (GitGutterStageHunk) endif - if !hasmapto('GitGutterUndoHunk') && maparg('hu', 'n') ==# '' - nmap hu GitGutterUndoHunk + if !hasmapto('(GitGutterUndoHunk)') && maparg('hu', 'n') ==# '' + nmap hu (GitGutterUndoHunk) endif - if !hasmapto('GitGutterPreviewHunk') && maparg('hp', 'n') ==# '' - nmap hp GitGutterPreviewHunk + if !hasmapto('(GitGutterPreviewHunk)') && maparg('hp', 'n') ==# '' + nmap hp (GitGutterPreviewHunk) endif - if !hasmapto('GitGutterTextObjectInnerPending') && maparg('ic', 'o') ==# '' - omap ic GitGutterTextObjectInnerPending + if !hasmapto('(GitGutterTextObjectInnerPending)') && maparg('ic', 'o') ==# '' + omap ic (GitGutterTextObjectInnerPending) endif - if !hasmapto('GitGutterTextObjectOuterPending') && maparg('ac', 'o') ==# '' - omap ac GitGutterTextObjectOuterPending + if !hasmapto('(GitGutterTextObjectOuterPending)') && maparg('ac', 'o') ==# '' + omap ac (GitGutterTextObjectOuterPending) endif - if !hasmapto('GitGutterTextObjectInnerVisual') && maparg('ic', 'x') ==# '' - xmap ic GitGutterTextObjectInnerVisual + if !hasmapto('(GitGutterTextObjectInnerVisual)') && maparg('ic', 'x') ==# '' + xmap ic (GitGutterTextObjectInnerVisual) endif - if !hasmapto('GitGutterTextObjectOuterVisual') && maparg('ac', 'x') ==# '' - xmap ac GitGutterTextObjectOuterVisual + if !hasmapto('(GitGutterTextObjectOuterVisual)') && maparg('ac', 'x') ==# '' + xmap ac (GitGutterTextObjectOuterVisual) endif call gitgutter#utility#setbufvar(bufnr, 'mapped', 1) diff --git a/autoload/gitgutter/hunk.vim b/autoload/gitgutter/hunk.vim index fea9083..d34546f 100644 --- a/autoload/gitgutter/hunk.vim +++ b/autoload/gitgutter/hunk.vim @@ -177,17 +177,17 @@ function! gitgutter#hunk#stage(...) abort else call s:hunk_op(function('s:stage')) endif - silent! call repeat#set("\GitGutterStageHunk", -1) + silent! call repeat#set("\(GitGutterStageHunk)", -1) endfunction function! gitgutter#hunk#undo() abort call s:hunk_op(function('s:undo')) - silent! call repeat#set("\GitGutterUndoHunk", -1) + silent! call repeat#set("\(GitGutterUndoHunk)", -1) endfunction function! gitgutter#hunk#preview() abort call s:hunk_op(function('s:preview')) - silent! call repeat#set("\GitGutterPreviewHunk", -1) + silent! call repeat#set("\(GitGutterPreviewHunk)", -1) endfunction diff --git a/doc/gitgutter.txt b/doc/gitgutter.txt index c2affb4..4a4fc64 100644 --- a/doc/gitgutter.txt +++ b/doc/gitgutter.txt @@ -232,9 +232,9 @@ These can be repeated with `.` if you have vim-repeat installed. You can change these mappings like this: > - nmap ghp GitGutterPreviewHunk - nmap ghs GitGutterStageHunk - nmap ghu GitGutterUndoHunk + nmap ghp (GitGutterPreviewHunk) + nmap ghs (GitGutterStageHunk) + nmap ghu (GitGutterUndoHunk) < Hunk jumping:~ @@ -247,8 +247,8 @@ Hunk jumping:~ You can change these mappings like this: > - nmap [c GitGutterPrevHunk - nmap ]c GitGutterNextHunk + nmap [c (GitGutterPrevHunk) + nmap ]c (GitGutterNextHunk) < 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 trailing empty lines. > - omap ic GitGutterTextObjectInnerPending - omap ac GitGutterTextObjectOuterPending - xmap ic GitGutterTextObjectInnerVisual - xmap ac GitGutterTextObjectOuterVisual + omap ic (GitGutterTextObjectInnerPending) + omap ac (GitGutterTextObjectOuterPending) + xmap ic (GitGutterTextObjectInnerVisual) + xmap ac (GitGutterTextObjectOuterVisual) < diff --git a/plugin/gitgutter.vim b/plugin/gitgutter.vim index 1758af2..6b75877 100644 --- a/plugin/gitgutter.vim +++ b/plugin/gitgutter.vim @@ -145,10 +145,10 @@ command! -bar GitGutterUndoHunk call gitgutter#hunk#undo() command! -bar GitGutterPreviewHunk call gitgutter#hunk#preview() " Hunk text object -onoremap GitGutterTextObjectInnerPending :call gitgutter#hunk#text_object(1) -onoremap GitGutterTextObjectOuterPending :call gitgutter#hunk#text_object(0) -xnoremap GitGutterTextObjectInnerVisual :call gitgutter#hunk#text_object(1) -xnoremap GitGutterTextObjectOuterVisual :call gitgutter#hunk#text_object(0) +onoremap (GitGutterTextObjectInnerPending) :call gitgutter#hunk#text_object(1) +onoremap (GitGutterTextObjectOuterPending) :call gitgutter#hunk#text_object(0) +xnoremap (GitGutterTextObjectInnerVisual) :call gitgutter#hunk#text_object(1) +xnoremap (GitGutterTextObjectOuterVisual) :call gitgutter#hunk#text_object(0) " 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 {{{ -nnoremap GitGutterNextHunk &diff ? ']c' : ":\execute v:count1 . 'GitGutterNextHunk'\" -nnoremap GitGutterPrevHunk &diff ? '[c' : ":\execute v:count1 . 'GitGutterPrevHunk'\" +nnoremap (GitGutterNextHunk) &diff ? ']c' : ":\execute v:count1 . 'GitGutterNextHunk'\" +nnoremap GitGutterNextHunk &diff ? ']c' : ":\call gitgutter#utility#warn('please change your map \Plug>GitGutterNextHunk to \Plug>(GitGutterNextHunk)')\" +nnoremap (GitGutterPrevHunk) &diff ? '[c' : ":\execute v:count1 . 'GitGutterPrevHunk'\" +nnoremap GitGutterPrevHunk &diff ? '[c' : ":\call gitgutter#utility#warn('please change your map \Plug>GitGutterPrevHunk to \Plug>(GitGutterPrevHunk)')\" -xnoremap GitGutterStageHunk :GitGutterStageHunk -nnoremap GitGutterStageHunk :GitGutterStageHunk -nnoremap GitGutterUndoHunk :GitGutterUndoHunk -nnoremap GitGutterPreviewHunk :GitGutterPreviewHunk +xnoremap (GitGutterStageHunk) :GitGutterStageHunk +xnoremap GitGutterStageHunk :call gitgutter#utility#warn('please change your map GitGutterStageHunk to (GitGutterStageHunk)') +nnoremap (GitGutterStageHunk) :GitGutterStageHunk +nnoremap GitGutterStageHunk :call gitgutter#utility#warn('please change your map GitGutterStageHunk to (GitGutterStageHunk)') +nnoremap (GitGutterUndoHunk) :GitGutterUndoHunk +nnoremap GitGutterUndoHunk :call gitgutter#utility#warn('please change your map GitGutterUndoHunk to (GitGutterUndoHunk)') +nnoremap (GitGutterPreviewHunk) :GitGutterPreviewHunk +nnoremap GitGutterPreviewHunk :call gitgutter#utility#warn('please change your map GitGutterPreviewHunk to (GitGutterPreviewHunk)') " }}}