2021-02-21 02:59:11 +00:00
|
|
|
;; -*- lexical-binding: t; -*-
|
|
|
|
|
2021-02-20 11:40:03 +00:00
|
|
|
;; Nicer minibuffer completion
|
|
|
|
|
|
|
|
;; First Selectrum, which provides the core incremental minibuffer completion engine
|
|
|
|
(use-package selectrum
|
|
|
|
:config
|
|
|
|
(selectrum-mode 1)
|
|
|
|
(leader-def-key "z" #'selectrum-repeat))
|
|
|
|
|
|
|
|
;; Then prescient, which adds the ability to sort and filter completions
|
|
|
|
(use-package selectrum-prescient
|
|
|
|
:after selectrum
|
|
|
|
:config
|
|
|
|
(selectrum-prescient-mode 1)
|
|
|
|
(prescient-persist-mode 1))
|
|
|
|
|
|
|
|
;; Marginalia adds annotations to completion candidates
|
|
|
|
(use-package marginalia
|
2021-02-20 23:23:04 +00:00
|
|
|
:demand t
|
2021-02-20 11:40:03 +00:00
|
|
|
:config
|
|
|
|
(marginalia-mode 1)
|
|
|
|
;; When using Selectrum, ensure that Selectrum is refreshed when cycling annotations.
|
|
|
|
(advice-add #'marginalia-cycle :after
|
|
|
|
(lambda ()
|
|
|
|
(when (bound-and-true-p selectrum-mode) (selectrum-exhibit))))
|
2021-10-14 15:57:44 +00:00
|
|
|
(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))
|
2021-02-20 11:40:03 +00:00
|
|
|
:general
|
|
|
|
(minibuffer-local-map "M-A" #'marginalia-cycle)
|
|
|
|
:custom
|
|
|
|
(marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil)))
|
|
|
|
|
2021-10-14 15:57:44 +00:00
|
|
|
;; Embark adds context actions to completion candidates (and other things!)
|
2021-02-20 11:40:03 +00:00
|
|
|
(use-package embark
|
|
|
|
:config
|
2021-10-14 15:57:44 +00:00
|
|
|
(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))
|
2021-02-20 11:40:03 +00:00
|
|
|
:general
|
2021-10-14 15:57:44 +00:00
|
|
|
("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)
|
2021-02-20 11:40:03 +00:00
|
|
|
('normal embark-collect-mode-map
|
2021-07-27 15:49:51 +00:00
|
|
|
"TAB" #'forward-button
|
|
|
|
"?" #'describe-mode
|
|
|
|
"A" #'embark-collect-direct-action-minor-mode
|
|
|
|
"S" #'tabulated-list-sort
|
|
|
|
"a" #'embark-act
|
|
|
|
"b" #'backward-button
|
|
|
|
"e" #'embark-export
|
|
|
|
"f" #'forward-button
|
|
|
|
"gr" #'revert-buffer
|
|
|
|
"n" #'next-line
|
|
|
|
"p" #'previous-line
|
|
|
|
"q" #'quit-window
|
|
|
|
"s" #'isearch-forward
|
|
|
|
"v" #'embark-collect-toggle-view
|
|
|
|
"z" #'embark-collect-zebra-minor-mode
|
|
|
|
"{" #'tabulated-list-narrow-current-column
|
|
|
|
"}" #'tabulated-list-widen-current-column
|
|
|
|
"<backtab>" #'backward-button)
|
2021-02-20 11:40:03 +00:00
|
|
|
:custom
|
2021-07-27 15:50:02 +00:00
|
|
|
(embark-prompter 'embark-keymap-prompter)
|
2021-10-14 15:57:44 +00:00
|
|
|
(embark-indicators '(embark-which-key-indicator
|
|
|
|
embark-highlight-indicator
|
|
|
|
embark-isearch-highlight-indicator)))
|
2021-02-20 11:40:03 +00:00
|
|
|
|
|
|
|
;; Consult adds a bunch of completing-read based utilities
|
|
|
|
(use-package consult
|
2021-02-24 21:51:11 +00:00
|
|
|
:commands (consult-xref)
|
|
|
|
:init
|
|
|
|
(setq xref-show-xrefs-function #'consult-xref
|
|
|
|
xref-show-definitions-function #'consult-xref)
|
|
|
|
:custom
|
|
|
|
(consult-project-root-function #'projectile-project-root)
|
2021-02-24 22:10:00 +00:00
|
|
|
(consult-config '((consult-ripgrep :preview-key nil)
|
|
|
|
(consult-grep :preview-key nil)))
|
2021-02-20 11:40:03 +00:00
|
|
|
:general
|
2021-02-20 19:57:40 +00:00
|
|
|
([remap switch-to-buffer] #'consult-buffer)
|
2021-02-21 03:02:33 +00:00
|
|
|
([remap imenu] #'consult-imenu)
|
2021-02-24 22:10:00 +00:00
|
|
|
([remap projectile-ripgrep] #'consult-ripgrep)
|
|
|
|
([remap projectile-grep] #'consult-grep)
|
2021-02-21 03:02:33 +00:00
|
|
|
("C-c p" #'consult-yank))
|
2021-02-20 11:40:03 +00:00
|
|
|
|
2021-02-24 21:51:11 +00:00
|
|
|
(use-package consult-flycheck
|
|
|
|
:after flycheck
|
|
|
|
:general
|
|
|
|
(flycheck-command-map "!" #'consult-flycheck))
|
|
|
|
|
2021-02-24 22:10:00 +00:00
|
|
|
(use-package embark-consult
|
2021-02-26 15:29:10 +00:00
|
|
|
:defer 1)
|
2021-02-24 23:55:01 +00:00
|
|
|
|
|
|
|
;; Make grep-like embark collect buffers editable
|
|
|
|
(use-package wgrep
|
|
|
|
:general
|
|
|
|
(grep-mode-map "C-x C-q" #'wgrep-change-to-wgrep-mode))
|
2021-02-24 22:10:00 +00:00
|
|
|
|
2021-02-20 11:40:03 +00:00
|
|
|
(provide 'init-completion)
|