From 4adf6f702d23064d58c965b575cd7a9a6df7506e Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Wed, 20 Sep 2023 06:09:23 +0200 Subject: [PATCH] Move from Ivy to Consult+Vertico+Orderless --- configuration.org | 271 +++++++++++++++++++++++++++++----------------- 1 file changed, 170 insertions(+), 101 deletions(-) diff --git a/configuration.org b/configuration.org index 3c57294..c3738e3 100644 --- a/configuration.org +++ b/configuration.org @@ -88,6 +88,15 @@ #+begin_src emacs-lisp (use-package emacs :ensure nil + :init + (defun crm-indicator (args) + (cons (format "[CRM%s] %s" + (replace-regexp-in-string + "\\`\\[.*?]\\*\\|\\[.*?]\\*\\" "" + crm-separator) + (car args)) + (cdr args))) + (advice-add #'completing-read-multiple :filter-args #'crm-indicator) :custom (user-full-name "Gergely Polonkai") (user-mail-address "gergely@polonkai.eu") @@ -110,7 +119,11 @@ (8250 8249) ; ›‹ (171 187) ; «» (187 171))) ; »« - (initial-scratch-message "")) + (initial-scratch-message "") + (minibuffer-prompt-properties '(read-only t cursor-intangible t face minibuffer-prompt)) + (enable-recursive-minibuffers t) + :hook + (minibuffer-setup . cursor-intangible-mode)) #+end_src ** Set up some default faces @@ -2357,6 +2370,15 @@ For all your spell-checking needs. (text-mode . flyspell-mode)) #+END_SRC +*** FlySpell with Ace + +#+begin_src emacs-lisp +(use-package ace-flyspell + :bind + (:map flyspell-mode-map + ("C-M-i" . ace-flyspell-correct-word))) +#+end_src + ** Delete all the whitespace #+BEGIN_SRC emacs-lisp @@ -2577,7 +2599,7 @@ accompanying function will be added to ~mu4e-view-mode-hook~. #+BEGIN_SRC emacs-lisp (use-package mu4e - :after ivy + :after vertico :ensure nil :config (require 'org-mu4e) @@ -2634,7 +2656,7 @@ accompanying function will be added to ~mu4e-view-mode-hook~. (message-sendmail-extra-arguments . ("--account=private" "--read-envelope-from"))))) org-mu4e-link-query-in-headers-mode nil) :custom - (mu4e-completing-read-function 'ivy-completing-read) + (mu4e-completing-read-function vertico-completing-read) (mu4e-context-policy 'pick-first) (mu4e-confirm-quit nil) (mail-user-agent 'sendmail-user-agent) @@ -2823,7 +2845,24 @@ I don’t always use the package menu, but when i do, i want to do it in style :global-prefix "S-SPC") (rune/leader-keys "t" '(:ignore t :which-key "toggles") - "tt" '(counsel-load-theme :which-key "choose theme"))) + "tt" '(consult-theme :which-key "choose theme"))) +#+end_src + +** BibTex + +First, set up ~bibtex-completion~: + +#+begin_src emacs-lisp +(use-package bibtex-completion + :after + org + :custom + (bibtex-completion-bibliography (expand-file-name "references.bib" org-directory)) + (bibtex-completion-library-path (expand-file-name "bibtex-pdfs" org-directory)) + (bibtex-completion-pdf-open-function 'org-open-file) + (bibtex-completion-notes-path (expand-file-name + (convert-standard-filename "bibliography/bibtex-notes") + org-directory))) #+end_src * Dired related packages @@ -3601,121 +3640,153 @@ See previous versions of the current file. (require 'company-web-html)) #+END_SRC -* Ivy & Co. +* Consult, Vertico, Orderless -** Ivy & Counsel +The new completing system! + +** Vertico #+begin_src emacs-lisp -(use-package ivy - :config - (ivy-mode 1) - :custom - (ivy-use-virtual-buffers t) - (ivy-count-format "(%d/%d) ") - (ivy-use-selectable-prompt t)) -(use-package counsel - :config - (counsel-mode) - :bind - (:map company-mode-map - ("C-c j" . counsel-company) - :map company-active-map - ("C-c j" . counsel-company)) - :custom - (counsel-find-file-ignore-regexp "\\(?:\\`\\|[/\\]\\)\\(?:[#.]\\)")) +(use-package vertico + :init + (vertico-mode)) #+end_src -** GNU Globals with Counsel +** Consult #+begin_src emacs-lisp -(defun gpolonkai/enable-counsel-gtags-mode () - (counsel-gtags-mode t)) - -(use-package counsel-gtags - :custom - (counsel-gtags-auto-update t) - (counsel-gtags-path-style 'relative) +(use-package consult + :bind (:map global-map + ([remap Info-search] . consult-info) + ("M-y" . consult-yank-pop) + :map mode-specific-map + ("M-x" . consult-mode-command) + ("h" . consult-history) + ("k" . consult-kmacro) + ("m" . consult-man) + ("i" . consult-info) + :map ctl-x-map + ("M-:" . consult-complex-command) + ("b" . consult-buffer) + ("4 b" . consult-buffer-other-window) + ("5 b" . consult-buffer-other-frame) + ("r b" . consult-bookmark) + ("x b" . consult-project-buffer) + :map goto-map + ("e" . consult-compile-error) + ("f" . consult-flymake) + ("g" . consult-goto-line) + ("M-g" . consult-goto-line) + ("o" . consult-org-heading) + ("m" . consult-mark) + ("k" . consult-global-mark) + ("i" . consult-imenu) + ("I" . consult-imenu-multi) + :map search-map + ("d" . consult-find) + ("D" . consult-locate) + ("g" . consult-grep) + ("G" . consult-git-grep) + ("r" . consult-ripgrep) + ("l" . consult-line) + ("L" . consult-line-multi) + ("k" . consult-keep-lines) + ("u" . consilt-focus-lines) + ("e" . consult-isearch-history) + :map isearch-mode-map + ("M-e" . consult-isearch-history) + :map minibuffer-local-map + ("M-s" . consult-history) + ("M-r" . consult-history)) :hook - (c-mode . gpolonkai/enable-counsel-gtags-mode) - :bind - (:map counsel-gtags-mode-map - ("M-t" . counsel-gtags-find-definition) - ("M-r" . counsel-gtags-find-reference) - ("M-s" . counsel-gtags-find-symbol) - ("C-c <" . counsel-gtags-go-backward) - ("C-c >" . counsel-gtags-go-forward))) -#+end_src - -** Ag with Counsel - -#+begin_src emacs-lisp -(use-package counsel-ag-popup - :bind - (:map gpolonkai/pers-map - ("s" . counsel-ag-popup))) -#+end_src - -** Projectile with Counsel - -#+begin_src emacs-lisp -(use-package counsel-projectile + (completion-list-mode . consult-preview-at-point-mode) :custom - (projectile-completion-system 'ivy) + (consult-narrow-key "<") + (consult-project-function (lambda (_) (projectile-project-root))) + (register-preview-delay 0.5) + (xref-show-xrefs-function #'consult-xref) + (xref-show-definitions-function #'consult-xref) + :init + (setq register-preview-function #'consult-register-format) + (advice-add #'register-preview :override #'consult-register-window) :config - (counsel-projectile-mode)) + (defalias 'consult-line-thing-at-point 'consult-line) + (consult-customize + consult-theme :preview-key '(:debounce 0.2 any) + consult-buffer :preview-key "M-." + consult-line-thing-at-point :initial (thing-at-point 'symbol) + consult-ripgrep + consult-git-grep + consult-grep + consult-bookmark + consult-recent-file + consult-xref + consult--source-bookmark + consult--source-file-register + consult--source-recent-file + consult--source-project-recent-file + :preview-key '(:debounce 0.4 any)) + (autoload 'projectile-project-root "projectile")) #+end_src -** FlySpell with Ace +** Orderless #+begin_src emacs-lisp -(use-package ace-flyspell - :bind - (:map flyspell-mode-map - ("C-M-i" . ace-flyspell-correct-word))) +(use-package orderless + :init + (setq completion-category-defaults nil) + :custom + (completion-styles '(orderless basic)) + (completion-category-overrides '((file (styles basic partial-completion))))) #+end_src -** C Yasnippets with Ivy +** Marginalia #+begin_src emacs-lisp -(use-package ivy-yasnippet +(use-package marginalia + :bind (:map minibuffer-local-map + ("M-A" . marginalia-cycle)) + :init + (marginalia-mode)) +#+end_src + +** Embark + +#+begin_src emacs-lisp +(use-package embark + :bind (:map global-map + ("C-." . embark-act)) + :config + (add-to-list 'display-buffer-alist + '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*" + nil + (window-parameters (mode-line-format . none))))) + +(use-package embark-consult + :hook + (embark-collect-mode . consult-preview-at-point-mode)) +#+end_src + +** Ag with Consult + +#+begin_src emacs-lisp +(use-package consult-ag) +#+end_src + +** Projectile with Consult + +#+begin_src emacs-lisp +(use-package consult-projectile) +#+end_src + +** Yasnippets with Consult + +#+begin_src emacs-lisp +(use-package consult-yasnippet :after yasnippet :bind - (("C-c y" . ivy-yasnippet))) -#+end_src - -** PyDoc with Counsel - -#+begin_src emacs-lisp -(use-package counsel-pydoc) -#+end_src - -** BibTex with Ivy - -First, set up ~bibtex-completion~: - -#+begin_src emacs-lisp -(use-package bibtex-completion - :after - org - :custom - (bibtex-completion-bibliography (expand-file-name "references.bib" org-directory)) - (bibtex-completion-library-path (expand-file-name "bibtex-pdfs" org-directory)) - (bibtex-completion-pdf-open-function 'org-open-file) - (bibtex-completion-notes-path (expand-file-name - (convert-standard-filename "bibliography/ivy-bibtex-notes") - org-directory))) -#+end_src - -#+begin_src emacs-lisp -(use-package ivy-bibtex - :after bibtex-completion) -#+end_src - -** Access passwords in pass using Ivy - -#+begin_src emacs-lisp -(use-package ivy-pass) + (("C-c y" . consult-yasnippet))) #+end_src * Mode specific ~use-package~ calls @@ -4068,7 +4139,7 @@ With the new Transient package it will be easier. I just don’t know how to us ("C-e" . gpolonkai/move-to-end-of-line) ("M-q" . sachachua/fill-or-unfill-paragraph) ("C-c r" . round-number-at-point-to-decimals) - ("C-s" . swiper) + ("C-s" . consult-line) ("C-r" . gpolonkai/isearch-regexp) ("C-M-s" . isearch-forward) ("C-M-r" . isearch-backward) @@ -4086,8 +4157,6 @@ With the new Transient package it will be easier. I just don’t know how to us ("M-k" . gpolonkai/undo-buffer-kill) ("C-b" . bury-buffer) ("/" . repeat) - ("C-f" . counsel-find-file) - ("b" . counsel-switch-buffer) :map isearch-mode-map ("" . isearch-exit-other-end) ("" . isearch-exit-mark-match)