about summary refs log tree commit diff stats
path: root/emacs-prelude/personal/lisp/init-git.el
blob: ac5ce4b8dafce4e5456df39da0cd1bf2939933af (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
(use-package magit
  :after key-chord
  :init
  (defun my/magit-set-upstream ()
    (interactive)
    (magit-shell-command-topdir "git upstream"))
  ;; update stale git info on the modeline (based on code removed from doom modeline)
  (defun my/magit-refresh-state ()
    (interactive)
    (dolist (buf (buffer-list))
            (when (and (not (buffer-modified-p buf))
                       (buffer-file-name buf)
                       (file-exists-p (buffer-file-name buf))
                       (file-in-directory-p (buffer-file-name buf) (magit-toplevel)))
              (with-current-buffer buf
                (vc-refresh-state)))))
  :config
  (key-chord-define-global "UU" 'my/magit-set-upstream)
  (key-chord-define-global "RR" 'my/magit-refresh-state)
  :custom (magit-diff-refine-hunk 'all))

(prelude-require-package 'forge)
(use-package forge
  :after magit)

(prelude-require-package 'git-gutter)
(use-package git-gutter
  :diminish
  :bind
  ("C-c j g" . git-gutter-mode)
  ("C-c j S-g" . git-gutter)
  ("C-c j n" . git-gutter:next-hunk)
  ("C-c j p" . git-gutter:previous-hunk)
  ("C-c j r" . git-gutter:revert-hunk)
  ("C-c j d" . git-gutter:popup-hunk))

(provide 'init-git)