aboutsummaryrefslogtreecommitdiff
path: root/emacs/settings/init-magit.el
blob: 7ddbc3c7a357191faaa026995513c84e71fe8c3d (plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
;;; init-magit.el --- Magit configuration

;; Copyright (C) 2016 Miquel Sabaté Solà <mikisabate@gmail.com>
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;;; Commentary:
;;
;; Magit configuration

;;; Code:

(require 'use-package)

(use-package magit
  :ensure t
  :config

  ; Proper initial states.
  (add-hook 'git-commit-mode-hook 'evil-insert-state)
  (evil-set-initial-state 'magit-log-edit-mode 'insert)

  ; When showing the status, hide the usually-redundant "branch" section and
  ; show the rest.
  (add-hook 'magit-section-set-visibility-hook
            '(lambda (section)
               (if (string= (magit-section-type section) "branch")
                   'hide
                 'show)))

  (eval-after-load 'evil-leader
    '(progn
       (evil-leader/set-key "s" 'magit-status)

       (use-package evil-magit
         :ensure t
         :config

         ; The magit + evil-magit combo messes up some chords, let's fix this.
         (evil-define-key 'normal magit-mode-map
           "\C-h" 'evil-window-left
           "\C-l" 'evil-window-right
           "\C-j" 'evil-window-down
           "\C-k" 'evil-window-up
           "\M-p"  'helm-projectile-switch-project)))))

(provide 'init-magit)
;;; init-magit.el ends here