Overall cleanup for emacs, trimmed alot to get to basics.
This commit is contained in:
+15
-25
@@ -1,19 +1,18 @@
|
||||
;;; git.el --- Magit, set up for Evil -*- lexical-binding: t; -*-
|
||||
;;; git.el --- Magit, minimal Evil -*- lexical-binding: t; -*-
|
||||
;;; Commentary:
|
||||
;; Loaded from init.el, which must set `evil-want-keybinding' to nil before
|
||||
;; Evil loads (Evil Collection needs it).
|
||||
;; Loaded from init.el after evil.el.
|
||||
;;
|
||||
;; :git Magit status for the current repo, full frame.
|
||||
;; q puts your previous window layout back.
|
||||
;; :git ARGS Run `git ARGS' from the repo root, e.g. :git log --oneline
|
||||
;;
|
||||
;; In Magit (Evil Collection layout):
|
||||
;; j/k move, TAB folds, s stage, u unstage, x discard, c c commit,
|
||||
;; p push, F pull, l log, d diff, b branch, z stash, gr refresh, q quit,
|
||||
;; ? lists every command.
|
||||
;; Commit message: opens in insert state; ZZ or C-c C-c commits,
|
||||
;; ZQ or C-c C-k cancels.
|
||||
;; Ctrl+hjkl, C-f and C-b keep their global meaning in Magit buffers.
|
||||
;; Magit buffers use Evil's emacs state, so every Magit key is native
|
||||
;; (s stage, u unstage, c c commit, P push, F pull, l log, d diff, b branch,
|
||||
;; z stash, g refresh, n/p sections, TAB folds, ? lists every command),
|
||||
;; except j/k, which move by line. That shadows Magit's own j (jump to
|
||||
;; section) and k (discard): use M-x magit-status-jump / magit-discard.
|
||||
;; If ESC drops you into normal state, C-z toggles emacs state back.
|
||||
;; Commit message: opens in insert state; C-c C-c commits, C-c C-k cancels.
|
||||
;;; Code:
|
||||
|
||||
(use-package magit
|
||||
@@ -23,22 +22,13 @@
|
||||
(magit-display-buffer-function #'magit-display-buffer-fullframe-status-v1)
|
||||
(magit-bury-buffer-function #'magit-restore-window-configuration))
|
||||
|
||||
;; Vim-style keys for Magit, its section folding, and the commit message buffer.
|
||||
;; (magit magit-submodule) is the form Evil Collection's own default list uses.
|
||||
(with-eval-after-load 'evil-collection
|
||||
;; Evil Collection puts section jumps on C-j/C-k and page scrolling on C-f/C-b.
|
||||
;; Unbind them so your window and Consult keys show through. Sibling sections
|
||||
;; are still on ] and [, and scrolling on C-d/C-u.
|
||||
(add-hook 'evil-collection-setup-hook
|
||||
(lambda (mode &rest _)
|
||||
(when (eq mode 'magit)
|
||||
(evil-define-key 'normal magit-mode-map
|
||||
(kbd "C-j") nil
|
||||
(kbd "C-k") nil
|
||||
(kbd "C-f") nil
|
||||
(kbd "C-b") nil))))
|
||||
;; All Magit buffers derive from magit-mode.
|
||||
(evil-set-initial-state 'magit-mode 'emacs)
|
||||
|
||||
(evil-collection-init '((magit magit-submodule) magit-section with-editor)))
|
||||
(with-eval-after-load 'magit-mode
|
||||
(evil-define-key 'emacs magit-mode-map
|
||||
"j" #'next-line
|
||||
"k" #'previous-line))
|
||||
|
||||
;; Commit messages start in insert state. Added after git-commit loads so its
|
||||
;; default hook functions are kept.
|
||||
|
||||
Reference in New Issue
Block a user