Add additional embark actions

This commit is contained in:
Jeremy Dormitzer 2021-10-14 11:57:44 -04:00
parent 12f97985a9
commit be797826ec
2 changed files with 68 additions and 6 deletions

View File

@ -24,19 +24,71 @@
(advice-add #'marginalia-cycle :after
(lambda ()
(when (bound-and-true-p selectrum-mode) (selectrum-exhibit))))
(add-to-list 'marginalia-prompt-categories '("Find file:" . project-file))
(add-to-list 'marginalia-prompt-categories '("Find dir:" . project-file))
(add-to-list 'marginalia-prompt-categories '("Switch to project" . file))
(add-to-list 'marginalia-prompt-categories '("recipe\\|package" . straight))
(add-to-list 'marginalia-prompt-categories '("Password entry" . password-store))
:general
(minibuffer-local-map "M-A" #'marginalia-cycle)
:custom
(marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil)))
;; Embark adds context actions to completion candidates
;; Embark adds context actions to completion candidates (and other things!)
(use-package embark
:config
(defun embark-which-key-indicator (map _target)
(which-key--show-keymap "Embark" map nil nil 'no-paging)
#'which-key--hide-popup-ignore-command)
(defun embark-which-key-indicator ()
"An embark indicator that displays keymaps using which-key.
The which-key help message will show the type and value of the
current target followed by an ellipsis if there are further
targets."
(lambda (&optional keymap targets prefix)
(if (null keymap)
(which-key--hide-popup-ignore-command)
(which-key--show-keymap
(if (eq (caar targets) 'embark-become)
"Become"
(format "Act on %s '%s'%s"
(plist-get (car targets) :type)
(embark--truncate-target (plist-get (car targets) :target))
(if (cdr targets) "" "")))
(if prefix
(pcase (lookup-key keymap prefix 'accept-default)
((and (pred keymapp) km) km)
(_ (key-binding prefix 'accept-default)))
keymap)
nil nil t))))
(embark-define-keymap embark-straight-map
"Keymap for actions for straight.el"
("u" straight-visit-package-website)
("r" straight-get-recipe)
("i" straight-use-package)
("c" straight-check-package)
("F" straight-pull-package)
("f" straight-fetch-package)
("p" straight-push-package)
("n" straight-normalize-package)
("m" straight-merge-package))
(add-to-list 'embark-keymap-alist '(straight . embark-straight-map))
(embark-define-keymap embark-password-store-actions
"Keymap for actions for password-store."
("c" password-store-copy)
("f" password-store-copy-field)
("i" password-store-insert)
("I" password-store-generate)
("r" password-store-rename)
("e" password-store-edit)
("k" password-store-remove)
("U" password-store-url))
(add-to-list 'embark-keymap-alist '(password-store . embark-password-store-actions))
:general
("M-o" #'embark-act)
("C-." #'embark-act)
("M-." #'embark-dwim)
('normal "C-." #'embark-act)
('normal "M-." #'embark-dwim)
(embark-file-map "s" #'sudo-edit-find-file
"l" #'vlf
"g" #'magit-file-dispatch)
('normal embark-collect-mode-map
"TAB" #'forward-button
"?" #'describe-mode
@ -58,7 +110,9 @@
"<backtab>" #'backward-button)
:custom
(embark-prompter 'embark-keymap-prompter)
(embark-indicator 'embark-which-key-indicator))
(embark-indicators '(embark-which-key-indicator
embark-highlight-indicator
embark-isearch-highlight-indicator)))
;; Consult adds a bunch of completing-read based utilities
(use-package consult

View File

@ -23,6 +23,14 @@
(set-visited-file-name new-name)
(set-buffer-modified-p nil))
(use-package sudo-edit
:commands (sudo-edit
sudo-edit-find-file))
;; Optimized editing of very large files
(use-package vlf
:commands (vlf))
(leader-def-key
"f" '(nil :which-key "file")
"ff" #'find-file