Add configuration option to disable key maps.

And add a little documentation.
This commit is contained in:
Andy Stewart
2014-01-13 11:01:14 +01:00
parent c680694b06
commit ae81dccb67
3 changed files with 51 additions and 8 deletions

View File

@@ -93,6 +93,12 @@ nmap <Leader>ha <Plug>GitGutterStageHunk
nmap <Leader>hu <Plug>GitGutterRevertHunk
```
If you don't want vim-gitgutter to set up any mappings at all, use this:
```viml
let g:gitgutter_map_keys = 0
```
Finally, you can force vim-gitgutter to update its signs across all visible buffers with `:GitGutterAll`.
See the customisation section below for how to change the defaults.
@@ -121,6 +127,7 @@ You can customise:
* The signs' colours and symbols
* Line highlights
* Extra arguments for `git diff`
* Key mappings
* Whether or not to escape `grep` (default to no)
* Whether or not vim-gitgutter is on initially (defaults to on)
* Whether or not signs are shown (defaults to yes)
@@ -197,6 +204,17 @@ If you want to pass extra arguments to `git diff`, for example to ignore whitesp
let g:gitgutter_diff_args = '-w'
```
#### Key mappings
To disable all key mappings:
```viml
let g:gitgutter_map_keys = 0`
```
See above for configuring maps for hunk-jumping and staging/reverting.
#### Whether or not to escape `grep`
If you have `grep` aliased to something which changes its output, for example `grep --color=auto -H`, you will need to tell vim-gitgutter to use raw grep:

View File

@@ -103,6 +103,7 @@ You can customise:
- The signs' colours and symbols
- Line highlights
- Extra arguments for git-diff
- Key mappings
- Whether or not to escape grep (defaults to no)
- Whether or not vim-gitgutter is on initially (defaults to on)
- Whether or not signs are shown (defaults to yes)
@@ -189,6 +190,25 @@ To pass extra arguments to git-diff, add this to your |vimrc|:
let g:gitgutter_diff_args = '-w'
<
KEY MAPPINGS
To disable all key maps:
>
let g:gitgutter_map_keys = 0
<
To change the hunk-jumping maps:
>
nmap [h <Plug>GitGutterPrevHunk
nmap ]h <Plug>GitGutterNextHunk
<
To change the hunk-staging/reverting maps:
>
nmap <Leader>hs <Plug>GitGutterStageHunk
nmap <Leader>hr <Plug>GitGutterRevertHunk
<
TO ESCAPE GREP
To avoid any alias you have for grep, use this:

View File

@@ -27,6 +27,7 @@ call s:set('g:gitgutter_sign_removed', '_')
call s:set('g:gitgutter_sign_modified_removed', '~_')
call s:set('g:gitgutter_diff_args', '')
call s:set('g:gitgutter_escape_grep', 0)
call s:set('g:gitgutter_map_keys', 1)
call highlight#define_sign_column_highlight()
call highlight#define_highlights()
@@ -248,20 +249,24 @@ endfunction
nnoremap <silent> <Plug>GitGutterNextHunk :<C-U>execute v:count1 . "GitGutterNextHunk"<CR>
nnoremap <silent> <Plug>GitGutterPrevHunk :<C-U>execute v:count1 . "GitGutterPrevHunk"<CR>
if !hasmapto('<Plug>GitGutterNextHunk') && maparg(']h', 'n') ==# ''
if g:gitgutter_map_keys
if !hasmapto('<Plug>GitGutterNextHunk') && maparg(']h', 'n') ==# ''
nmap ]h <Plug>GitGutterNextHunk
nmap [h <Plug>GitGutterPrevHunk
endif
endif
nnoremap <silent> <Plug>GitGutterStageHunk :GitGutterStageHunk<CR>
nnoremap <silent> <Plug>GitGutterRevertHunk :GitGutterRevertHunk<CR>
if !hasmapto('<Plug>GitGutterStageHunk') && maparg('<Leader>ha', 'n') ==# ''
if g:gitgutter_map_keys
if !hasmapto('<Plug>GitGutterStageHunk') && maparg('<Leader>ha', 'n') ==# ''
nmap <Leader>ha <Plug>GitGutterStageHunk
endif
if !hasmapto('<Plug>GitGutterRevertHunk') && maparg('<Leader>hr', 'n') ==# ''
endif
if !hasmapto('<Plug>GitGutterRevertHunk') && maparg('<Leader>hr', 'n') ==# ''
nmap <Leader>hr <Plug>GitGutterRevertHunk
endif
endif