|
| 1 | +;;; evil-magit-rebellion.el --- Key-bindings for evil magit rebels |
| 2 | + |
| 3 | +;; Copyright © 2013-2014 Albert Krewinkel |
| 4 | +;; |
| 5 | +;; Author: Albert Krewinkel <[email protected]> |
| 6 | +;; Keywords: evil magit rebellion |
| 7 | +;; |
| 8 | +;; This program is free software; you can redistribute it and/or modify |
| 9 | +;; it under the terms of the GNU General Public License as published by |
| 10 | +;; the Free Software Foundation, either version 3 of the License, or |
| 11 | +;; (at your option) any later version. |
| 12 | + |
| 13 | +;; This program is distributed in the hope that it will be useful, |
| 14 | +;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | +;; GNU General Public License for more details. |
| 17 | + |
| 18 | +;; This file is not part of GNU Emacs. |
| 19 | + |
| 20 | +;; You should have received a copy of the GNU General Public License |
| 21 | +;; along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 22 | + |
| 23 | +;;; Code: |
| 24 | + |
| 25 | +;; Start to insert mode when editing commit messages |
| 26 | +(evil-set-initial-state 'magit-log-edit-mode 'insert) |
| 27 | +(evil-set-initial-state 'git-commit-mode 'insert) |
| 28 | + |
| 29 | +;; "1" 'magit-show-level-1 |
| 30 | +;; "2" 'magit-show-level-2 |
| 31 | +;; "3" 'magit-show-level-3 |
| 32 | +;; "4" 'magit-show-level-4 |
| 33 | +(evil-set-initial-state 'magit-mode 'motion) |
| 34 | +(evil-define-key 'motion magit-mode-map |
| 35 | + "\M-1" 'magit-show-level-1-all |
| 36 | + "\M-2" 'magit-show-level-2-all |
| 37 | + "\M-3" 'magit-show-level-3-all |
| 38 | + "\M-4" 'magit-show-level-4-all |
| 39 | + "\M-H" 'magit-show-only-files-all |
| 40 | + "\M-S" 'magit-show-level-4-all |
| 41 | + "\M-h" 'magit-show-only-files |
| 42 | + "\M-s" 'magit-show-level-4 |
| 43 | + "!" 'magit-key-mode-popup-running |
| 44 | + "$" 'magit-process |
| 45 | + "+" 'magit-diff-larger-hunks |
| 46 | + "-" 'magit-diff-smaller-hunks |
| 47 | + "=" 'magit-diff-default-hunks |
| 48 | + "/" 'evil-search-forward |
| 49 | + ":" 'evil-ex |
| 50 | + ";" 'magit-git-command |
| 51 | + "?" 'evil-search-backward |
| 52 | + "<" 'magit-key-mode-popup-stashing |
| 53 | + "A" 'magit-cherry-pick-item |
| 54 | + "B" 'magit-key-mode-popup-bisecting |
| 55 | + ;C commit add log |
| 56 | + "D" 'magit-revert-item |
| 57 | + "E" 'magit-ediff |
| 58 | + "F" 'magit-key-mode-popup-pulling |
| 59 | + "G" 'evil-goto-line |
| 60 | + "H" 'magit-rebase-step |
| 61 | + ;I ignore item locally |
| 62 | + "J" 'magit-key-mode-popup-apply-mailbox |
| 63 | + "K" 'magit-key-mode-popup-dispatch |
| 64 | + "L" 'magit-add-change-log-entry |
| 65 | + "M" 'magit-key-mode-popup-remoting |
| 66 | + "N" 'evil-search-previous |
| 67 | + ;O undefined |
| 68 | + "P" 'magit-key-mode-popup-pushing |
| 69 | + ;Q undefined |
| 70 | + "R" 'magit-refresh-all |
| 71 | + "S" 'magit-stage-all |
| 72 | + ;T change what branch tracks |
| 73 | + "U" 'magit-unstage-all |
| 74 | + ;V visual line |
| 75 | + "W" 'magit-diff-working-tree |
| 76 | + "X" 'magit-reset-working-tree |
| 77 | + "Y" 'magit-interactive-rebase |
| 78 | + "Z" 'magit-key-mode-popup-stashing |
| 79 | + "a" 'magit-apply-item |
| 80 | + "b" 'magit-key-mode-popup-branching |
| 81 | + "c" 'magit-key-mode-popup-committing |
| 82 | + ;d discard |
| 83 | + "e" 'magit-diff |
| 84 | + "f" 'magit-key-mode-popup-fetching |
| 85 | + "g?" 'magit-describe-item |
| 86 | + "g$" 'evil-end-of-visual-line |
| 87 | + "g0" 'evil-beginning-of-visual-line |
| 88 | + "gE" 'evil-backward-WORD-end |
| 89 | + "g^" 'evil-first-non-blank-of-visual-line |
| 90 | + "g_" 'evil-last-non-blank |
| 91 | + "gd" 'evil-goto-definition |
| 92 | + "ge" 'evil-backward-word-end |
| 93 | + "gg" 'evil-goto-first-line |
| 94 | + "gj" 'evil-next-visual-line |
| 95 | + "gk" 'evil-previous-visual-line |
| 96 | + "gm" 'evil-middle-of-visual-line |
| 97 | + "h" 'magit-key-mode-popup-rewriting |
| 98 | + ;i ignore item |
| 99 | + "j" 'magit-goto-next-section |
| 100 | + "k" 'magit-goto-previous-section |
| 101 | + "l" 'magit-key-mode-popup-logging |
| 102 | + "m" 'magit-key-mode-popup-merging |
| 103 | + "n" 'evil-search-next |
| 104 | + "o" 'magit-key-mode-popup-submodule |
| 105 | + "p" 'magit-cherry |
| 106 | + "q" 'magit-mode-quit-window |
| 107 | + "r" 'magit-refresh |
| 108 | + ;s stage |
| 109 | + "t" 'magit-key-mode-popup-tagging |
| 110 | + ;u unstage |
| 111 | + "v" 'magit-revert-item |
| 112 | + "w" 'magit-wazzup |
| 113 | + "x" 'magit-reset-head |
| 114 | + "y" 'magit-copy-item-as-kill |
| 115 | + ;z position current line |
| 116 | + " " 'magit-show-item-or-scroll-up |
| 117 | + "\d" 'magit-show-item-or-scroll-down |
| 118 | + "\t" 'magit-toggle-section |
| 119 | + (kbd "<return>") 'magit-visit-item |
| 120 | + (kbd "C-<return>") 'magit-dired-jump |
| 121 | + (kbd "<backtab>") 'magit-expand-collapse-section |
| 122 | + (kbd "C-x 4 a") 'magit-add-change-log-entry-other-window |
| 123 | + (kbd "\M-d") 'magit-copy-item-as-kill) |
| 124 | + |
| 125 | +;;; Redefine some bindings if rigid key bindings are expected |
| 126 | +;(when magit-rigid-key-bindings |
| 127 | +; (evil-define-key 'motion magit-mode-map |
| 128 | +; "!" 'magit-git-command-topdir |
| 129 | +; "B" 'undefined |
| 130 | +; "F" 'magit-pull |
| 131 | +; "J" 'magit-apply-mailbox |
| 132 | +; "M" 'magit-branch-manager |
| 133 | +; "P" 'magit-push |
| 134 | +; "b" 'magit-checkout |
| 135 | +; "c" 'magit-commit |
| 136 | +; "f" 'magit-fetch-current |
| 137 | +; "h" 'undefined |
| 138 | +; "l" 'magit-log |
| 139 | +; "m" 'magit-merge |
| 140 | +; "o" 'magit-submodule-update |
| 141 | +; "t" 'magit-tag |
| 142 | +; "z" 'magit-stash)) |
| 143 | + |
| 144 | +(defun evil-magit-rebellion-quit-keymode () |
| 145 | + (interactive) |
| 146 | + (magit-key-mode-command nil)) |
| 147 | + |
| 148 | +(evil-set-initial-state 'magit-commit-mode 'motion) |
| 149 | +(evil-define-key 'motion magit-commit-mode-map |
| 150 | + "\C-c\C-b" 'magit-show-commit-backward |
| 151 | + "\C-c\C-f" 'magit-show-commit-forward) |
| 152 | + |
| 153 | +(evil-set-initial-state 'magit-status-mode 'motion) |
| 154 | +(evil-define-key 'motion magit-status-mode-map |
| 155 | + "\C-f" 'evil-scroll-page-down |
| 156 | + "\C-b" 'evil-scroll-page-up |
| 157 | + "." 'magit-mark-item |
| 158 | + "=" 'magit-diff-with-mark |
| 159 | + "C" 'magit-add-log |
| 160 | + "I" 'magit-ignore-item-locally |
| 161 | + "S" 'magit-stage-all |
| 162 | + "U" 'magit-unstage-all |
| 163 | + "X" 'magit-reset-working-tree |
| 164 | + "d" 'magit-discard-item |
| 165 | + "i" 'magit-ignore-item |
| 166 | + "s" 'magit-stage-item |
| 167 | + "u" 'magit-unstage-item |
| 168 | + "z" 'magit-key-mode-popup-stashing) |
| 169 | + |
| 170 | +(evil-set-initial-state 'magit-log-mode 'motion) |
| 171 | +(evil-define-key 'motion magit-log-mode-map |
| 172 | + "." 'magit-mark-item |
| 173 | + "=" 'magit-diff-with-mark |
| 174 | + "e" 'magit-log-show-more-entries) |
| 175 | + |
| 176 | +(evil-set-initial-state 'magit-wassup-mode 'motion) |
| 177 | +(evil-define-key 'motion magit-wazzup-mode-map |
| 178 | + "." 'magit-mark-item |
| 179 | + "=" 'magit-diff-with-mark |
| 180 | + "i" 'magit-ignore-item) |
| 181 | + |
| 182 | +(evil-set-initial-state 'magit-branch-manager-mode 'motion) |
| 183 | +(evil-define-key 'motion magit-branch-manager-mode-map |
| 184 | + "d" 'magit-remove-branch |
| 185 | + "D" 'magit-remove-branch-in-remote-repo |
| 186 | + "v" 'magit-show-branches |
| 187 | + "T" 'magit-change-what-branch-tracks) |
| 188 | + |
| 189 | +(provide 'evil-magit-rebellion) |
0 commit comments