diff --git a/modules/completion/selectrum/README.org b/modules/completion/selectrum/README.org index 2eff299e8..d6ff6c683 100644 --- a/modules/completion/selectrum/README.org +++ b/modules/completion/selectrum/README.org @@ -28,6 +28,7 @@ TODO instead of orderless. ** Plugins +[[https://github.com/minad/vertico][vertico]] (~+vertico~, experimental for the moment) [[https://github.com/raxod502/selectrum][selectrum]] [[https://github.com/minad/consult][consult]] [[https://github.com/oantolin/embark/][embark]] diff --git a/modules/completion/selectrum/TODO.org b/modules/completion/selectrum/TODO.org index af7b4f441..48d91cf87 100644 --- a/modules/completion/selectrum/TODO.org +++ b/modules/completion/selectrum/TODO.org @@ -66,7 +66,32 @@ Do we want to have the annotations be more like ivy? e.g. =:completion selectrum= is a bit of a misnomer. Selectrum is probably the most easily replaceable part of the module as it can replaced with Vertico fairly easily, other than losing the ~selectrum-repeat~ command. However, -naming is hardâ„¢. Best alternative I can think of is =:completion modular=. +naming is hardâ„¢. Best alternative I can think of is this: +#+begin_src emacs-lisp +:completion +;... +;ivy ;; a search engine for love and life +compleseus ;; a search engine with all the planks replaced +#+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. * PROJ HACKs to be addressed ** TODO ~fboundp~ issues diff --git a/modules/completion/selectrum/autoload/selectrum.el b/modules/completion/selectrum/autoload/selectrum.el index 14d4f2a3e..55e97f630 100644 --- a/modules/completion/selectrum/autoload/selectrum.el +++ b/modules/completion/selectrum/autoload/selectrum.el @@ -123,12 +123,24 @@ Supports exporting consult-grep to wgrep, file to wdeired, and consult-location (defun +selectrum/next-candidate-preview () "Move to next candidate and preivew it" (interactive) - (selectrum-next-candidate) + (if (featurep! :completion selectrum +vertico) + (vertico-next) + (selectrum-next-candidate)) (+selectrum/embark-preview)) ;;;###autoload (defun +selectrum/previous-candidate-preview () "Move to previous candidate and preview it" (interactive) - (selectrum-previous-candidate) + (if (featurep! :completion selectrum +vertico) + (vertico-previous) + (selectrum-previous-candidate)) (+selectrum/embark-preview)) + +;;;###autoload +(defun +selectrum/repeat () + "Repeat the last selectrum/vertico command." + (interactive) + (if (featurep! :completion selectrum +vertico) + (user-error "The vertico flag doesn't support repeating commands (yet)") + (selectrum-repeat))) diff --git a/modules/completion/selectrum/config.el b/modules/completion/selectrum/config.el index e28904181..18a337de0 100644 --- a/modules/completion/selectrum/config.el +++ b/modules/completion/selectrum/config.el @@ -1,6 +1,7 @@ ;;; 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 @@ -12,6 +13,17 @@ (map! :map selectrum-minibuffer-map [backspace] #'+selectrum/backward-updir)) +(use-package! vertico + :when (featurep! +vertico) + :hook (doom-first-input . vertico-mode) + :init + (setq vertico-resize nil + vertico-count 17 + vertico-cycle t) + :config + (map! :map vertico-map + [backspace] #'+selectrum/backward-updir)) + (use-package! selectrum-prescient :when (featurep! +prescient) :hook (selectrum-mode . selectrum-prescient-mode) @@ -41,11 +53,14 @@ (setq completion-styles '(orderless) completion-category-defaults nil ;; note that despite override in the name orderless can still be used in find-file etc. - completion-category-overrides '((file (styles . (partial-completion)))) + completion-category-overrides '((file (styles . (orderless partial-completion)))) orderless-style-dispatchers '(+selectrum-orderless-dispatch) - orderless-component-separator "[ &]" - selectrum-refine-candidates-function #'orderless-filter - selectrum-highlight-candidates-function #'orderless-highlight-matches)) + orderless-component-separator "[ &]") + ;; otherwise find-file gets different highlighting than other commands + (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 :defer t diff --git a/modules/completion/selectrum/packages.el b/modules/completion/selectrum/packages.el index 585cae552..f66d1f329 100644 --- a/modules/completion/selectrum/packages.el +++ b/modules/completion/selectrum/packages.el @@ -1,7 +1,11 @@ ;; -*- no-byte-compile: t; -*- ;;; completion/selectrum/packages.el -(package! selectrum :pin "a19bbe94de492bf504399c093cfc5695eb630fa8") +(if (featurep! +vertico) + (package! vertico + :recipe (:host github :repo "minad/vertico") + :pin "c9157759a015ac32cb299c18c84c6d5fb34e0aa1") + (package! selectrum :pin "a19bbe94de492bf504399c093cfc5695eb630fa8")) (if (featurep! +prescient) (package! selectrum-prescient :pin "4a0f5405798cfcb98ea005078ef2e2d490e922c4") diff --git a/modules/config/default/+emacs-bindings.el b/modules/config/default/+emacs-bindings.el index b3a7e72d2..a454e7ed6 100644 --- a/modules/config/default/+emacs-bindings.el +++ b/modules/config/default/+emacs-bindings.el @@ -464,7 +464,7 @@ "C-S-s" #'swiper-helm "C-S-r" #'helm-resume) (:when (featurep! :completion selectrum) - "C-S-r" #'selectrum-repeat) + "C-S-r" #'+selectrum/repeat) ;;; objed (:when (featurep! :editor objed +manual) diff --git a/modules/config/default/+evil-bindings.el b/modules/config/default/+evil-bindings.el index 3fd8e7892..cf2427141 100644 --- a/modules/config/default/+evil-bindings.el +++ b/modules/config/default/+evil-bindings.el @@ -204,16 +204,29 @@ [C-return] #'helm-grep-run-other-window-action)) (:when (featurep! :completion selectrum) - (: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))) + (:when (featurep! :completion selectrum +vertico) + (:after vertico + :map vertico-map + "M-RET" #'vertico-exit-input + "C-SPC" #'+selectrum/embark-preview + "C-j" #'vertico-next + "C-M-j" #'+selectrum/next-candidate-preview + "C-S-j" #'vertico-next-group + "C-k" #'vertico-previous + "C-M-k" #'+selectrum/previous-candidate-preview + "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 (map! (:when (featurep! :ui popup) @@ -305,7 +318,7 @@ :desc "Resume last search" "'" (cond ((featurep! :completion ivy) #'ivy-resume) ((featurep! :completion helm) #'helm-resume) - ((featurep! :completion selectrum) #'selectrum-repeat)) + ((featurep! :completion selectrum) #'+selectrum/repeat)) :desc "Search for symbol in project" "*" #'+default/search-project-for-symbol-at-point :desc "Search project" "/" #'+default/search-project