aboutsummaryrefslogtreecommitdiff
path: root/.config/emacs/lisp/evil-collection/modes/diff-hl
diff options
context:
space:
mode:
authorJack Jamison <jackqjamison@gmail.com>2026-07-05 01:19:30 -0400
committerJack Jamison <jackqjamison@gmail.com>2026-07-05 01:19:30 -0400
commitbdf9a71ab7baa2b1de9abcfd5df1a9107a55d141 (patch)
treec4524e6c41aa5107211103401dabfaefc81aa882 /.config/emacs/lisp/evil-collection/modes/diff-hl
parentfe3984f541bd32bdfa418afb305b614176b55ca0 (diff)
add a bunch of emacs packages HELP
Diffstat (limited to '.config/emacs/lisp/evil-collection/modes/diff-hl')
-rw-r--r--.config/emacs/lisp/evil-collection/modes/diff-hl/README.org29
-rw-r--r--.config/emacs/lisp/evil-collection/modes/diff-hl/evil-collection-diff-hl.el75
2 files changed, 104 insertions, 0 deletions
diff --git a/.config/emacs/lisp/evil-collection/modes/diff-hl/README.org b/.config/emacs/lisp/evil-collection/modes/diff-hl/README.org
new file mode 100644
index 0000000..67e87a7
--- /dev/null
+++ b/.config/emacs/lisp/evil-collection/modes/diff-hl/README.org
@@ -0,0 +1,29 @@
+* diff-hl
+
+ Evil bindings for [[https://github.com/dgutov/diff-hl][diff-hl]]'s show-hunk popup and inline overlay.
+
+ Also adds =evil-normalize-keymaps= to
+ =diff-hl-show-hunk-inline-transient-mode-hook= so the bindings take
+ effect when the transient mode toggles on.
+
+** Key bindings
+
+*** diff-hl-show-hunk-map
+
+ | Command | Original | Evil |
+ |----------------------------------------+----------+------|
+ | =diff-hl-show-hunk-previous= | =p=, ={= | =p= |
+ | =diff-hl-show-hunk-next= | =n=, =}= | =n= |
+ | =diff-hl-show-hunk-copy-original-text= | =c= | =c= |
+ | =diff-hl-show-hunk-revert-hunk= | =r= | =r= |
+ | =diff-hl-show-hunk-stage-hunk= | =S= | =S= |
+
+*** diff-hl-show-hunk-inline-transient-mode-map
+
+ | Command | Original | Evil |
+ |--------------------------------------------+-------------------+------------|
+ | =diff-hl-show-hunk-inline-hide= | =q=, =C-g=, =ESC= | =q=, =ESC= |
+ | =diff-hl-show-hunk-inline--popup-down= | =<down>=, =C-n= | =j= |
+ | =diff-hl-show-hunk-inline--popup-up= | =<up>=, =C-p= | =k= |
+ | =diff-hl-show-hunk-inline--popup-pagedown= | =<next>=, =C-v= | =C-f= |
+ | =diff-hl-show-hunk-inline--popup-pageup= | =<prior>=, =M-v= | =C-b= |
diff --git a/.config/emacs/lisp/evil-collection/modes/diff-hl/evil-collection-diff-hl.el b/.config/emacs/lisp/evil-collection/modes/diff-hl/evil-collection-diff-hl.el
new file mode 100644
index 0000000..9a9fe5b
--- /dev/null
+++ b/.config/emacs/lisp/evil-collection/modes/diff-hl/evil-collection-diff-hl.el
@@ -0,0 +1,75 @@
+;;; evil-collection-diff-hl.el --- Evil bindings for diff-hl -*- lexical-binding: t -*-
+
+;; Copyright (C) 2021 Zhiwei Chen
+
+;; Author: Zhiwei Chen <condy0919@gmail.com>
+;; Maintainer: James Nguyen <james@jojojames.com>
+;; Pierre Neidhardt <mail@ambrevar.xyz>
+;; URL: https://github.com/emacs-evil/evil-collection
+;; Version: 0.0.1
+;; Package-Requires: ((emacs "26.3"))
+;; Keywords: evil, diff, tools
+
+;; 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.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;; Evil bindings for diff-hl.
+;;
+;; All functions used below are autoloaded except for
+;; `diff-hl-show-hunk-inline--popup-down' et al commands.
+;;
+;; When users invoke `diff-hl-show-hunk' (it invokes
+;; `diff-hl-show-hunk-function' under the hood), `diff-hl-show-hunk-inline.el' or
+;; `diff-hl-show-hunk-posframe.el' will be loaded eventually.
+;;
+;; So there is no
+;;
+;; (require 'diff-hl nil t)
+;;
+;; below.
+
+;;; Code:
+(require 'evil-collection)
+
+(defconst evil-collection-diff-hl-maps '(diff-hl-show-hunk-map
+ diff-hl-show-hunk-inline-transient-mode-map))
+
+;;;###autoload
+(defun evil-collection-diff-hl-setup()
+ "Set up `evil' bindings for `diff-hl'."
+ (add-hook 'diff-hl-show-hunk-inline-transient-mode-hook 'evil-normalize-keymaps)
+
+ (evil-collection-define-key 'normal 'diff-hl-show-hunk-inline-transient-mode-map
+ ;; quit
+ "q" 'diff-hl-show-hunk-inline-hide
+ (kbd "<escape>") 'diff-hl-show-hunk-inline-hide
+
+ ;; motion
+ "j" 'diff-hl-show-hunk-inline--popup-down
+ "k" 'diff-hl-show-hunk-inline--popup-up
+ (kbd "C-f") 'diff-hl-show-hunk-inline--popup-pagedown
+ (kbd "C-b") 'diff-hl-show-hunk-inline--popup-pageup)
+
+ ;; Actually `diff-hl-show-hunk-inline-transient-mode-map' will inherit it by
+ ;; `set-keymap-parent'.
+ (evil-collection-define-key 'normal 'diff-hl-show-hunk-map
+ ;; Keep it the same as the overlay shows.
+ "p" 'diff-hl-show-hunk-previous
+ "n" 'diff-hl-show-hunk-next
+ "c" 'diff-hl-show-hunk-copy-original-text
+ "r" 'diff-hl-show-hunk-revert-hunk
+ "S" 'diff-hl-show-hunk-stage-hunk))
+
+(provide 'evil-collection-diff-hl)
+;;; evil-collection-diff-hl.el ends here