From ae81dccb679a423f871809d83c6829442760748a Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Mon, 13 Jan 2014 11:01:14 +0100 Subject: [PATCH] Add configuration option to disable key maps. And add a little documentation. --- README.mkd | 18 ++++++++++++++++++ doc/gitgutter.txt | 20 ++++++++++++++++++++ plugin/gitgutter.vim | 21 +++++++++++++-------- 3 files changed, 51 insertions(+), 8 deletions(-) diff --git a/README.mkd b/README.mkd index cf83797..4df90b5 100644 --- a/README.mkd +++ b/README.mkd @@ -93,6 +93,12 @@ nmap ha GitGutterStageHunk nmap hu 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: diff --git a/doc/gitgutter.txt b/doc/gitgutter.txt index 22cab4c..c7ed528 100644 --- a/doc/gitgutter.txt +++ b/doc/gitgutter.txt @@ -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 GitGutterPrevHunk + nmap ]h GitGutterNextHunk +< + +To change the hunk-staging/reverting maps: +> + nmap hs GitGutterStageHunk + nmap hr GitGutterRevertHunk +< + TO ESCAPE GREP To avoid any alias you have for grep, use this: diff --git a/plugin/gitgutter.vim b/plugin/gitgutter.vim index 8a172a3..3f0f491 100644 --- a/plugin/gitgutter.vim +++ b/plugin/gitgutter.vim @@ -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 GitGutterNextHunk :execute v:count1 . "GitGutterNextHunk" nnoremap GitGutterPrevHunk :execute v:count1 . "GitGutterPrevHunk" -if !hasmapto('GitGutterNextHunk') && maparg(']h', 'n') ==# '' - nmap ]h GitGutterNextHunk - nmap [h GitGutterPrevHunk +if g:gitgutter_map_keys + if !hasmapto('GitGutterNextHunk') && maparg(']h', 'n') ==# '' + nmap ]h GitGutterNextHunk + nmap [h GitGutterPrevHunk + endif endif nnoremap GitGutterStageHunk :GitGutterStageHunk nnoremap GitGutterRevertHunk :GitGutterRevertHunk -if !hasmapto('GitGutterStageHunk') && maparg('ha', 'n') ==# '' - nmap ha GitGutterStageHunk -endif -if !hasmapto('GitGutterRevertHunk') && maparg('hr', 'n') ==# '' - nmap hr GitGutterRevertHunk +if g:gitgutter_map_keys + if !hasmapto('GitGutterStageHunk') && maparg('ha', 'n') ==# '' + nmap ha GitGutterStageHunk + endif + if !hasmapto('GitGutterRevertHunk') && maparg('hr', 'n') ==# '' + nmap hr GitGutterRevertHunk + endif endif