From acafda9c59b0b7e8350fefc92bc2dfcccc4bd3f0 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 22 Jan 2021 23:27:25 -0600 Subject: Add selectrum, prescient, consult, marginalia --- config.org | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/config.org b/config.org index ed4a474..07e63af 100644 --- a/config.org +++ b/config.org @@ -494,6 +494,128 @@ to /hide/ those contents. read-file-name-completion-ignore-case t) #+end_src +*** Selectrum :package: + +My minibuffer completion system uses =selectrum=, =prescient=, =company=, +and =marginalia=. At some point, I'd like to take a deep dive in =embark= +(possibly switching out =selectrum=), =ido=, =orderless=, or others, +for now .... I just want to see my completions. + +#+begin_src emacs-lisp :noweb-ref packages + (straight-use-package 'selectrum) +#+end_src + +#+begin_src emacs-lisp :noweb-ref modes + (selectrum-mode +1) +#+end_src + +*** Prescient + +#+begin_src emacs-lisp :noweb-ref packages + (straight-use-package 'prescient) + (require 'prescient) +#+end_src + +Prescient can persist itself too. + +#+begin_src emacs-lisp :noweb-ref modes + (prescient-persist-mode +1) +#+end_src + +Let's have =prescient= and =selectrum= work together. + +#+begin_src emacs-lisp :noweb-ref packages + (straight-use-package 'selectrum-prescient) +#+end_src + +#+begin_src emacs-lisp :noweb-ref modes + (with-eval-after-load 'selectrum + (selectrum-prescient-mode +1)) +#+end_src + +*** Consult + +#+begin_src emacs-lisp :noweb-ref modes + (straight-use-package 'consult) + (require 'consult) +#+end_src + +Consult has a lot of great bindings that work well with Emacs's +default completion system. These all come from the [[https://github.com/minad/consult#configuration][example configuration]]. + +#+begin_src emacs-lisp :noweb-ref bindings + (with-eval-after-load 'consult + ;; C-c bindings (`mode-specific-map') + (define-key acdw/map (kbd "C-c h") #'consult-history) + (define-key acdw/map (kbd "C-c m") #'consult-mode-command) + ;; C-x bindings (`ctl-x-map') + (define-key acdw/map (kbd "C-x M-:") #'consult-complex-command) + (define-key acdw/map (kbd "C-x b") #'consult-buffer) + (define-key acdw/map (kbd "C-x 4 b") #'consult-buffer-other-window) + (define-key acdw/map (kbd "C-x 5 b") #'consult-buffer-other-frame) + (define-key acdw/map (kbd "C-x r x") #'consult-register) + (define-key acdw/map (kbd "C-x r b") #'consult-bookmark) + ;; M-g bindings (`goto-map') + (define-key acdw/map (kbd "M-g g") #'consult-line) + (define-key acdw/map (kbd "M-g M-g") #'consult-line) + (define-key acdw/map (kbd "M-g o") #'consult-outline) + (define-key acdw/map (kbd "M-g m") #'consult-mark) + (define-key acdw/map (kbd "M-g k") #'consult-global-mark) + (define-key acdw/map (kbd "M-g i") #'consult-imenu) + (define-key acdw/map (kbd "M-g e") #'consult-error) + ;; M-s bindings (`search-map') + (define-key acdw/map (kbd "M-s g") #'consult-grep) ; alts: + ; consult-git-grep, + ; consult-ripgrep + (define-key acdw/map (kbd "M-s f") #'consult-find) ; alts: + ; consult-locate + (define-key acdw/map (kbd "M-s l") #'consult-line) + (define-key acdw/map (kbd "M-s m") #'consult-multi-occur) + (define-key acdw/map (kbd "M-s k") #'consult-keep-lines) + (define-key acdw/map (kbd "M-s u") #'consult-focus-lines) + ;; Other bindings + (define-key acdw/map (kbd "M-y") #'consult-yank-pop) + (define-key acdw/map (kbd " a") #'consult-apropos)) +#+end_src + +#+begin_src emacs-lisp :noweb-ref settings + (autoload 'consult-register-preview "consult") ; make the compiler happy + (setq-default register-preview-delay 0 + register-preview-function #'consult-register-preview) +#+end_src + +*** Marginalia + +Finally, =marginalia= provides extra information about completion +candidates. + +#+begin_src emacs-lisp :noweb-ref packages + (straight-use-package 'marginalia) + (require 'marginalia) +#+end_src + +#+begin_src emacs-lisp :noweb-ref modes + (marginalia-mode +1) +#+end_src + +I like the rich annotations provided by =marginalia=. + +#+begin_src emacs-lisp :noweb-ref settings + (setq-default marginalia-annotators + '(marginalia-annotators-heavy + marginalia-annotators-light + nil)) +#+end_src + +**** Integration with Selectrum + +#+begin_src emacs-lisp :noweb-ref functions + (advice-add #'marginalia-cycle :after + (lambda () + (when (bound-and-true-p selectrum-mode) + (selectrum-exhibit)))) +#+end_src + ** Completion *** Hippie Expand -- cgit 1.4.1-21-gabe81