completion/selectrum -> completion/vertico, part 1

- Use `vertico` as default completion engine
- Drop `selectrum` and `selectrum-prescient` support
This commit is contained in:
Itai Y. Efrat 2021-07-09 19:59:44 +03:00
parent dc6da589be
commit f9e1c99b2b
9 changed files with 27 additions and 129 deletions

View file

@ -46,7 +46,7 @@ completion.
+ helm =+fuzzy +childframe= - *Another* search engine for love and life + helm =+fuzzy +childframe= - *Another* search engine for love and life
+ ido - The /other/ *other* search engine for love and life + ido - The /other/ *other* search engine for love and life
+ [[file:../modules/completion/ivy/README.org][ivy]] =+fuzzy +prescient +childframe +icons= - /The/ search engine for love and life + [[file:../modules/completion/ivy/README.org][ivy]] =+fuzzy +prescient +childframe +icons= - /The/ search engine for love and life
+ [[file:../modules/completion/selectrum/README.org][selectrum]] =+prescient +icons= - The search engine of the future + [[file:../modules/completion/selectrum/README.org][selectrum]] =+icons= - The search engine of the future
* :config * :config
Modules that configure Emacs one way or another, or focus on making it easier Modules that configure Emacs one way or another, or focus on making it easier

View file

@ -12,11 +12,11 @@
- [[#jump-to-navigation][Jump-to navigation]] - [[#jump-to-navigation][Jump-to navigation]]
- [[#project-search--replace][Project search & replace]] - [[#project-search--replace][Project search & replace]]
- [[#in-buffer-searching][In-buffer searching]] - [[#in-buffer-searching][In-buffer searching]]
- [[#selectrum-integration-for-various-completing-commands][Selectrum integration for various completing commands]] - [[#vertico-integration-for-various-completing-commands][Vertico integration for various completing commands]]
- [[#orderless-filtering][Orderless filtering]] - [[#orderless-filtering][Orderless filtering]]
* Description * Description
This module provides Selectrum integration for a variety of Emacs commands, as This module provides Vertico integration for a variety of Emacs commands, as
well as a unified interface for project search and replace, powered by ripgrep. well as a unified interface for project search and replace, powered by ripgrep.
#+begin_quote #+begin_quote
@ -24,20 +24,16 @@ TODO
#+end_quote #+end_quote
** Module Flags ** Module Flags
+ ~+prescient~ Enables prescient filtering and sorting for Selectrum searches
instead of orderless.
+ ~+icons~ Adds icons to ~file~ and ~buffer~ category completion selections. + ~+icons~ Adds icons to ~file~ and ~buffer~ category completion selections.
** Plugins ** Plugins
[[https://github.com/minad/vertico][vertico]] (~+vertico~, experimental for the moment) [[https://github.com/minad/vertico][vertico]]
[[https://github.com/raxod502/selectrum][selectrum]]
[[https://github.com/minad/consult][consult]] [[https://github.com/minad/consult][consult]]
[[https://github.com/oantolin/embark/][embark]] [[https://github.com/oantolin/embark/][embark]]
[[https://github.com/oantolin/embark/][embark-consult]] [[https://github.com/oantolin/embark/][embark-consult]]
[[https://github.com/minad/marginalia][marginalia]] [[https://github.com/minad/marginalia][marginalia]]
[[https://github.com/oantolin/orderless][orderless]] (unless ~+prescient~) [[https://github.com/oantolin/orderless][orderless]]
[[https://github.com/mhayashi1120/Emacs-wgrep][wgrep]] [[https://github.com/mhayashi1120/Emacs-wgrep][wgrep]]
[[https://github.com/raxod502/prescient.el][prescient]] (~+prescient~)
[[https://github.com/minad/consult/][consult-flycheck]] (~:checkers syntax~) [[https://github.com/minad/consult/][consult-flycheck]] (~:checkers syntax~)
[[https://github.com/iyefrat/all-the-icons-completion][all-the-icons-completion]] (~+icons~) [[https://github.com/iyefrat/all-the-icons-completion][all-the-icons-completion]] (~+icons~)
@ -121,12 +117,12 @@ https://assets.doomemacs.org/completion/selectrum/buffer-search.png
An ~occur-edit~ buffer can be opened from ~consult-line~ with =C-c C-e=. An ~occur-edit~ buffer can be opened from ~consult-line~ with =C-c C-e=.
** Selectrum integration for various completing commands ** Vertico integration for various completing commands
*** General *** General
| Keybind | Description | | Keybind | Description |
|----------------+-------------------------------| |----------------+-----------------------------|
| =M-x=, =SPC := | Enhanced M-x | | =M-x=, =SPC := | Enhanced M-x |
| =SPC '= | Resume last Selectrum session | | =SPC '= | Resume last Vertico session |
*** Jump to files, buffers or projects *** Jump to files, buffers or projects
| Keybind | Description | | Keybind | Description |

View file

@ -31,21 +31,16 @@ case for why this should be an exception:
- selectrum is slated to become the default completion module, which makes this - selectrum is slated to become the default completion module, which makes this
less of an inconsistency, but I'm not sure about the performance slowdown in less of an inconsistency, but I'm not sure about the performance slowdown in
~map!~ since that seems to be one of the main concerns. ~map!~ since that seems to be one of the main concerns.
- ~embark~ like most packages in the selectrum cinematic universe can be - ~embark~ like most packages in the vertico cinematic universe can be
installed independently, so if you find it sufficiently useful you could also installed independently, so if you find it sufficiently useful you could also
have a stripped down version of the config in doom core that is just used for have a stripped down version of the config in doom core that is just used for
on-buffer actions. on-buffer actions.
** TODO Consider dropping prescient flag
The only advantage over orderless is frecency over recency, without the better
integration orderless has with built in emacs completion. A compromise might be
to have ~+prescient~ just add prescient sorting, but it's probably not worth the
maintenance burden.
** TODO =SPC s s= and =SPC s S= ~:sw~ ? ** TODO =SPC s s= and =SPC s S= ~:sw~ ?
There isn't really a selectrum analogue to ~swiper-isearch~, ~consult-isearch~ There isn't really a vertico/consult analogue to ~swiper-isearch~, ~consult-isearch~
does something else (give you previously used isearch search terms). Bound to does something else (give you previously used isearch search terms). Bound to
regular isearch for now. regular isearch for now.
** TODO =SPC s B= ** TODO =SPC s B=
Selectrum/Consult don't have a ~swiper-all~ analogue either. Unbound for now. Vertico/Consult don't have a ~swiper-all~ analogue either. Unbound for now.
** TODO Orderless style dispatchers ** TODO Orderless style dispatchers
Currently the =!= style dispatcher is only as a prefix, due to the abundance of Currently the =!= style dispatcher is only as a prefix, due to the abundance of
=!= final macros. In my opinion this is useful enough to break consistency. =!= final macros. In my opinion this is useful enough to break consistency.
@ -73,37 +68,12 @@ naming is hard™. Best alternative I can think of is this:
;ivy ;; a search engine for love and life ;ivy ;; a search engine for love and life
compleseus ;; a search engine with all the planks replaced compleseus ;; a search engine with all the planks replaced
#+end_src #+end_src
** TODO Consider dropping Selectrum in favor of Vertico:
To this end there is currently a ~+vertico~ flag to try it out, weird naming
aside. I want to do this for a few reasons:
*** Selectrum is more buggy
Selectrum has a few longstanding bugs that don't exist in Vertico, namely: [[https://github.com/raxod502/selectrum/issues/491][491]]
and [[https://github.com/raxod502/selectrum/issues/561][561]], as well as having worse handling when having lines of varying height
(important for good icon support).
*** Feature Comparison
- Minad, Vertico's author, provides a detailed comparison [[https://github.com/hlissner/doom-emacs/pull/4664#issuecomment-871524782][here]]. I will note
however that I was seriously considering the switch before he wrote this
comparison due to the frustration of dealing with the rough edges.
- Vertico doesn't support prescient, but I want to drop it anyway.
- The [[https://github.com/raxod502/selectrum#vertico][feature comparison]] in the selectrum readme has been updated to better
reflect the current state of affairs. Both Vertico and Selectrum have some
features that the other package lacks. In my mind Vertico's features are more
useful, but the feature difference is small enough for it to be less important
than the bugginess imo.
*** Vertico is more actively maintained
This might be a temporary concern, but still.
** TODO Icon support
The icon support works well enough when using Vertico, but is a bit dodgy on
Selectrum due to it not handling lines of varying height that well, which ends
up causing the selection to slide off the screen when moving it the to the
bottom in some cases. Hopefully we just use Vertico and this becomes a nonissue,
but it should still be taken into account.
* PROJ HACKs to be addressed * PROJ HACKs to be addressed
** TODO ~fboundp~ issues ** TODO ~fboundp~ issues
Even if the =ivy= module isn't loaded, it's packages can still get loaded by Even if the =ivy= module isn't loaded, it's packages can still get loaded by
other means, such as =lispy= requiring =counsel=. This means that the ~fboundp~ other means, such as =lispy= requiring =counsel=. This means that the ~fboundp~
logic [[file:~/.emacs.d/modules/config/default/autoload/text.el::(cond ((fboundp 'consult-yank-pop) #'consult-yank-pop) ;;HACK see @ymarco's comment on #5013 and TODO.org][here]] (and formerly [[file:~/.emacs.d/core/autoload/projects.el::(and (bound-and-true-p ivy-mode][here]]) won't work unless the selectrum option is checked logic [[file:~/.emacs.d/modules/config/default/autoload/text.el::(cond ((fboundp 'consult-yank-pop) #'consult-yank-pop) ;;HACK see @ymarco's comment on #5013 and TODO.org][here]] (and formerly [[file:~/.emacs.d/core/autoload/projects.el::(and (bound-and-true-p ivy-mode][here]]) won't work unless the vertico option is checked
first, which is what we do for now. first, which is what we do for now.
** TODO ~projectile-switch-project-action~ definition ** TODO ~projectile-switch-project-action~ definition
Without [[file:~/.emacs.d/modules/ui/workspaces/config.el::;; HACK?? needs review][this]] change new projects don't get opened in a new tab, but the exact Without [[file:~/.emacs.d/modules/ui/workspaces/config.el::;; HACK?? needs review][this]] change new projects don't get opened in a new tab, but the exact
@ -122,7 +92,7 @@ the other one. This can be reproduces on emacs -Q.
This is due to orderless adding a bunch of other matches. This is due to orderless adding a bunch of other matches.
* PROJ Review non-blocking Issues * PROJ Review non-blocking Issues
** TODO Profile selectrum =SPC /= vs ivy =SPC /= ** TODO Profile vertico =SPC /= vs ivy =SPC /=
Check if there are other places where optimisations can be made. Perhaps the Check if there are other places where optimisations can be made. Perhaps the
~command-input-async~ variables can tolorate lower values. ~command-input-async~ variables can tolorate lower values.
** TODO ~(defadvice! +orderless-match-with-one-face..~ causes lexical error ** TODO ~(defadvice! +orderless-match-with-one-face..~ causes lexical error
@ -130,17 +100,8 @@ Probably caused by some doomism
https://github.com/oantolin/orderless/issues/41 https://github.com/oantolin/orderless/issues/41
* PROJ Upstream Issues
** TODO Selectrum separators cause size calculation bug
https://github.com/raxod502/selectrum/issues/491
** TODO ~selectrum-repeat~ doesn't scroll to previously selected candidate
Unlike Ivy, ~selectrum-repeat~ doesn't restore the position of the selection in
the completion buffer. Seems to be reproduced in ~emacs -Q~. If so, create
upstream selectrum issue.
** TODO Marginalia annotations sometimes disappear on ~find-file~
https://github.com/raxod502/selectrum/issues/561
* PROJ Extra credit * PROJ Extra credit
** ~vertico-repeat~ doesn't reselect the candidate
** TODO =bibtex-actions= improvements? ** TODO =bibtex-actions= improvements?
Currently =SPC n b= is bound to a function, but =bibtex-actions= doesn't have a Currently =SPC n b= is bound to a function, but =bibtex-actions= doesn't have a
main dispatch function like =ivy-bibtex=, rather it has a bunch of different main dispatch function like =ivy-bibtex=, rather it has a bunch of different

View file

@ -124,24 +124,12 @@ Supports exporting consult-grep to wgrep, file to wdeired, and consult-location
(defun +selectrum/next-candidate-preview () (defun +selectrum/next-candidate-preview ()
"Move to next candidate and preivew it" "Move to next candidate and preivew it"
(interactive) (interactive)
(if (featurep! :completion selectrum +vertico)
(vertico-next) (vertico-next)
(selectrum-next-candidate))
(+selectrum/embark-preview)) (+selectrum/embark-preview))
;;;###autoload ;;;###autoload
(defun +selectrum/previous-candidate-preview () (defun +selectrum/previous-candidate-preview ()
"Move to previous candidate and preview it" "Move to previous candidate and preview it"
(interactive) (interactive)
(if (featurep! :completion selectrum +vertico)
(vertico-previous) (vertico-previous)
(selectrum-previous-candidate))
(+selectrum/embark-preview)) (+selectrum/embark-preview))
;;;###autoload
(defun +selectrum/repeat ()
"Repeat the last selectrum/vertico command."
(interactive)
(if (featurep! :completion selectrum +vertico)
(vertico-repeat)
(selectrum-repeat)))

View file

@ -1,25 +1,6 @@
;;; completion/selectrum/config.el -*- lexical-binding: t; -*- ;;; completion/selectrum/config.el -*- lexical-binding: t; -*-
(use-package! selectrum
:when (not (featurep! +vertico))
:hook (doom-first-input . selectrum-mode)
:init
(setq selectrum-extend-current-candidate-highlight t
selectrum-fix-vertical-window-height t
selectrum-max-window-height 17)
(when (featurep! +prescient)
(setq completion-styles '(substring partial-completion)))
(add-hook 'selectrum-mode-hook (lambda ()
(setq completion-in-region-function
(if selectrum-mode
#'consult-completion-in-region
#'completion--in-region))))
:config
(map! :map selectrum-minibuffer-map
[backspace] #'+selectrum/backward-updir))
(use-package! vertico (use-package! vertico
:when (featurep! +vertico)
:hook (doom-first-input . vertico-mode) :hook (doom-first-input . vertico-mode)
:init :init
(setq vertico-resize nil (setq vertico-resize nil
@ -34,13 +15,7 @@
(map! :map vertico-map (map! :map vertico-map
[backspace] #'+selectrum/backward-updir)) [backspace] #'+selectrum/backward-updir))
(use-package! selectrum-prescient
:when (featurep! +prescient)
:hook (selectrum-mode . selectrum-prescient-mode)
:hook (selectrum-mode . prescient-persist-mode))
(use-package! orderless (use-package! orderless
:when (not (featurep! +prescient))
:demand t :demand t
:config :config
(defun +selectrum-orderless-dispatch (pattern _index _total) (defun +selectrum-orderless-dispatch (pattern _index _total)
@ -67,10 +42,7 @@
orderless-style-dispatchers '(+selectrum-orderless-dispatch) orderless-style-dispatchers '(+selectrum-orderless-dispatch)
orderless-component-separator "[ &]") orderless-component-separator "[ &]")
;; otherwise find-file gets different highlighting than other commands ;; otherwise find-file gets different highlighting than other commands
(set-face-attribute 'completions-first-difference nil :inherit nil) (set-face-attribute 'completions-first-difference nil :inherit nil))
(unless (featurep! +vertico)
(setq selectrum-refine-candidates-function #'orderless-filter
selectrum-highlight-candidates-function #'orderless-highlight-matches)))
(use-package! consult (use-package! consult
:defer t :defer t

View file

@ -1,16 +1,12 @@
;; -*- no-byte-compile: t; -*- ;; -*- no-byte-compile: t; -*-
;;; completion/selectrum/packages.el ;;; completion/selectrum/packages.el
(if (featurep! +vertico) (package! vertico
(package! vertico
:recipe (:host github :repo "minad/vertico" :recipe (:host github :repo "minad/vertico"
:files ("*.el" "extensions/*.el")) :files ("*.el" "extensions/*.el"))
:pin "9f6cd5d431ec6d288676af80e932d928346a1b36") :pin "9f6cd5d431ec6d288676af80e932d928346a1b36")
(package! selectrum :pin "48ea51aa5b6959ea2a134e36cd21f727047b0677"))
(if (featurep! +prescient) (package! orderless :pin "2646dad28c0819fbe9ee521d39efb9ae40e03982")
(package! selectrum-prescient :pin "4a0f5405798cfcb98ea005078ef2e2d490e922c4")
(package! orderless :pin "2646dad28c0819fbe9ee521d39efb9ae40e03982"))
(package! consult :pin "f17db9520ddd612dc837f4112b6bcbb172acef85") (package! consult :pin "f17db9520ddd612dc837f4112b6bcbb172acef85")
(when (featurep! :checkers syntax) (when (featurep! :checkers syntax)

View file

@ -464,7 +464,7 @@
"C-S-s" #'swiper-helm "C-S-s" #'swiper-helm
"C-S-r" #'helm-resume) "C-S-r" #'helm-resume)
(:when (featurep! :completion selectrum) (:when (featurep! :completion selectrum)
"C-S-r" #'+selectrum/repeat) "C-S-r" #'vertico-repeat)
;;; objed ;;; objed
(:when (featurep! :editor objed +manual) (:when (featurep! :editor objed +manual)

View file

@ -204,7 +204,6 @@
[C-return] #'helm-grep-run-other-window-action)) [C-return] #'helm-grep-run-other-window-action))
(:when (featurep! :completion selectrum) (:when (featurep! :completion selectrum)
(:when (featurep! :completion selectrum +vertico)
(:after vertico (:after vertico
:map vertico-map :map vertico-map
"M-RET" #'vertico-exit-input "M-RET" #'vertico-exit-input
@ -214,18 +213,7 @@
"C-S-j" #'vertico-next-group "C-S-j" #'vertico-next-group
"C-k" #'vertico-previous "C-k" #'vertico-previous
"C-M-k" #'+selectrum/previous-candidate-preview "C-M-k" #'+selectrum/previous-candidate-preview
"C-S-k" #'vertico-previous-group)) "C-S-k" #'vertico-previous-group)))
(:when (not (featurep! :completion selectrum +vertico))
(:after selectrum
:map selectrum-minibuffer-map
"M-RET" #'selectrum-submit-exact-input
"C-SPC" #'+selectrum/embark-preview
"C-j" #'selectrum-next-candidate
"C-M-j" #'+selectrum/next-candidate-preview
"C-S-j" #'selectrum-next-page
"C-k" #'selectrum-previous-candidate
"C-M-k" #'+selectrum/previous-candidate-preview
"C-S-k" #'selectrum-previous-page))))
;;; :ui ;;; :ui
@ -318,7 +306,7 @@
:desc "Resume last search" "'" :desc "Resume last search" "'"
(cond ((featurep! :completion ivy) #'ivy-resume) (cond ((featurep! :completion ivy) #'ivy-resume)
((featurep! :completion helm) #'helm-resume) ((featurep! :completion helm) #'helm-resume)
((featurep! :completion selectrum) #'+selectrum/repeat)) ((featurep! :completion selectrum) #'vertico-repeat))
:desc "Search for symbol in project" "*" #'+default/search-project-for-symbol-at-point :desc "Search for symbol in project" "*" #'+default/search-project-for-symbol-at-point
:desc "Search project" "/" #'+default/search-project :desc "Search project" "/" #'+default/search-project

View file

@ -135,9 +135,6 @@ In all cases, 'h' functions go to 'c' and 'l' ones go to 'r' so the navigation k
(after! helm-files (after! helm-files
(+layout-bepo-rotate-bare-keymap '(helm-read-file-map) +layout-bepo-cr-rotation-style) (+layout-bepo-rotate-bare-keymap '(helm-read-file-map) +layout-bepo-cr-rotation-style)
(+layout-bepo-rotate-keymaps '(helm-read-file-map))) (+layout-bepo-rotate-keymaps '(helm-read-file-map)))
(after! selectrum
(+layout-bepo-rotate-bare-keymap '(selectrum-minibuffer-map) +layout-bepo-cr-rotation-style)
(+layout-bepo-rotate-keymaps '(selectrum-minibuffer-map)))
(after! company (after! company
(+layout-bepo-rotate-bare-keymap '(company-active-map company-search-map) +layout-bepo-cr-rotation-style)) (+layout-bepo-rotate-bare-keymap '(company-active-map company-search-map) +layout-bepo-cr-rotation-style))
(after! evil-snipe (after! evil-snipe