Make git-gutter keybindings work for both versions.

Also add SPC g h p keybinding to preview hunk.
This commit is contained in:
person808 2015-04-13 08:57:07 -10:00 committed by syl20bnr
parent 12ac8bcddd
commit 79431eb583
2 changed files with 27 additions and 24 deletions

View file

@ -286,6 +286,7 @@ Git gutter hunks commands start with `gh`:
<kbd>SPC g h N</kbd> | previous hunk in buffer
<kbd>SPC g h r</kbd> | revert current hunk
<kbd>SPC g h s</kbd> | stage current hunk
<kbd>SPC g h p</kbd> | preview current hunk
`Spacemacs` has custom fringe bitmaps for [git-gutter-fringe][git-gutter]:

View file

@ -72,7 +72,14 @@ which require an initialization must be listed explicitly in the list.")
(spacemacs|hide-lighter git-gutter-mode)
(if (and (not git-gutter-use-fringe)
global-linum-mode)
(git-gutter:linum-setup)))
(git-gutter:linum-setup))
(with-eval-after-load (or 'git-gutter 'git-gutter-fringe)
(evil-leader/set-key
"ghs" 'git-gutter:stage-hunk
"ghr" 'git-gutter:revert-hunk
"ghN" 'git-gutter:previous-hunk
"ghn" 'git-gutter:next-hunk
"ghp" 'git-gutter:popup-hunk)))
(defun git/init-git-gutter ()
(use-package git-gutter
@ -102,34 +109,29 @@ which require an initialization must be listed explicitly in the list.")
(setq git-gutter:hide-gutter t)
;; Don't need log/message.
(setq git-gutter:verbosity 0)
(evil-leader/set-key
"ghs" 'git-gutter:stage-hunk
"ghr" 'git-gutter:revert-hunk
"ghN" 'git-gutter:previous-hunk
"ghn" 'git-gutter:next-hunk)
;; (setq git-gutter:update-hooks '(after-save-hook after-revert-hook))
;; custom graphics that works nice with half-width fringes
(fringe-helper-define 'git-gutter-fr:added nil
"..X...."
"..X...."
"XXXXX.."
"..X...."
"..X...."
)
"..X...."
"..X...."
"XXXXX.."
"..X...."
"..X...."
)
(fringe-helper-define 'git-gutter-fr:deleted nil
"......."
"......."
"XXXXX.."
"......."
"......."
)
"......."
"......."
"XXXXX.."
"......."
"......."
)
(fringe-helper-define 'git-gutter-fr:modified nil
"..X...."
".XXX..."
"XXXXX.."
".XXX..."
"..X...."
))))
"..X...."
".XXX..."
"XXXXX.."
".XXX..."
"..X...."
))))
(defun git/init-git-messenger ()
(use-package git-messenger