merge: pull request #5353 from iyefrat/vertico-things

Improve `:completion vertico`
This commit is contained in:
Henrik Lissner 2021-09-15 01:00:04 +02:00 committed by GitHub
commit b0e084e416
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 244 additions and 115 deletions

View file

@ -18,10 +18,17 @@
- [[#general][General]] - [[#general][General]]
- [[#jump-to-files-buffers-or-projects][Jump to files, buffers or projects]] - [[#jump-to-files-buffers-or-projects][Jump to files, buffers or projects]]
- [[#search][Search]] - [[#search][Search]]
- [[#consult-modifications][Consult modifications]] - [[#file-path-completion][File Path Completion]]
- [[#consult][Consult]]
- [[#multiple-candidate-search][Multiple candidate search]]
- [[#async-search-commands][Async search commands]]
- [[#marginalia][Marginalia]] - [[#marginalia][Marginalia]]
- [[#orderless-filtering][Orderless filtering]] - [[#orderless-filtering][Orderless filtering]]
- [[#configuration][Configuration]] - [[#configuration][Configuration]]
- [[#vertico][Vertico]]
- [[#consult-1][Consult]]
- [[#marginalia-1][Marginalia]]
- [[#embark][Embark]]
* Description * Description
This module enhances the Emacs search and completion experience, and also This module enhances the Emacs search and completion experience, and also
@ -55,7 +62,10 @@ like =ivy= and =helm= do. The primary packages are:
+ [[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=)
* Prerequisites * Prerequisites
This module has no prerequisites. Some of the advanced filtering features in async =consult= commands require
=grep= and =ripgrep= to be built with support for [[https://www.pcre.org/][PCRE]] lookahead, see [[#async-search-commands][Async
search commands]] for more information. You can check if this is true for your
machine by running ~doom doctor~.
* Features * Features
@ -71,15 +81,13 @@ keybindings are available:
| Keybind | Description | | Keybind | Description |
|-----------------------+----------------------------------------------------| |-----------------------+----------------------------------------------------|
| =C-p= | Go to previous candidate |
| =C-n= | Go to next candidate |
| =C-k= | (evil) Go to previous candidate | | =C-k= | (evil) Go to previous candidate |
| =C-j= | (evil) Go to next candidate | | =C-j= | (evil) Go to next candidate |
| =C-M-k= | (evil) Go to previous group |
| =C-M-j= | (evil) Go to next group |
| =C-;= or =<leader> a= | Open an ~embark-act~ menu to chose a useful action | | =C-;= or =<leader> a= | Open an ~embark-act~ menu to chose a useful action |
| =C-c C-;= | export the current candidate list to a buffer | | =C-c C-;= | export the current candidate list to a buffer |
| =C-SPC= | Preview the current candidate | | =C-SPC= | Preview the current candidate |
| =C-M-k= | (evil) Go to previous candidate and preview. |
| =C-M-j= | (evil) Go to next candidate and preview. |
~embark-act~ will prompt you with a =which-key= menu with useful commands on the ~embark-act~ will prompt you with a =which-key= menu with useful commands on the
selected candidate or candidate list, depending on the completion category. Note selected candidate or candidate list, depending on the completion category. Note
@ -183,7 +191,16 @@ or the last workspace by typing =0 SPC=.
| =SPC s P= | Search another project | | =SPC s P= | Search another project |
| =SPC s s= | Search the current buffer (incrementally) | | =SPC s s= | Search the current buffer (incrementally) |
** Consult modifications *** File Path Completion
Note that Emacs allows you to switch directories with shadow paths, for example
starting at =/foo/bar/baz=, typing =/foo/bar/baz/~/= will switch the searched
path to the home directory. For more information see ~substitute-in-file-name~
and ~file-name-shadow-mode~. This module will erase the "shadowed" portion of
the path from the minibuffer, so in the previous example the path will be reset
to =~/=.
** Consult
*** Multiple candidate search
This module modifies the default keybindings used in This module modifies the default keybindings used in
~consult-completing-read-multiple~: ~consult-completing-read-multiple~:
| Keybind | Description | | Keybind | Description |
@ -191,11 +208,32 @@ This module modifies the default keybindings used in
| =TAB= | Select or deselect current candidate | | =TAB= | Select or deselect current candidate |
| =RET= | Enters selected candidates (also toggles current candidate) | | =RET= | Enters selected candidates (also toggles current candidate) |
*** Async search commands
Consult async commands (e.g. ~consult-ripgrep~) will have a preceding separator
character (usually =#=) before the search input. This is known as the =perl=
splitting style. Input typed after the separator will be fed to the async
command until you type a second seperator, afterwhich the candidate list will be
filtered with Emacs instead (and can be filtered using =orderless=, for
example). The specific seperator character can be changed by editing it, and
might be different if the initial input already contains =#=.
Note that grep-like async commands translate the input (between the first and
second =#=) to an Orderless-light expression: space separated inputs are all
matched in any order. If the grep backend does not support PCRE lookahead, it'll
only accept 3 space separated inputs to prevent long lookup times, and further
filtering should be done after a second =#=.
For more information [[https://github.com/minad/consult#asynchronous-search][see here]].
** Marginalia ** Marginalia
| Keybind | Description | | Keybind | Description |
|---------+---------------------------------| |---------+---------------------------------|
| =M-A= | Cycle between annotation levels | | =M-A= | Cycle between annotation levels |
Marginalia annotations for symbols (e.g. =SPC h f= and =SPC h v=) come with
extra information the nature of the symbol. For the meaning of the annotations
see ~marginalia--symbol-class~.
** Orderless filtering ** Orderless filtering
When using orderless to filter through candidates, the default behaviour is for When using orderless to filter through candidates, the default behaviour is for
each space separated input to match the candidate as a regular expression or each space separated input to match the candidate as a regular expression or
@ -212,19 +250,35 @@ pressing space and entering another input. In essence, when trying to match
Doom has some builtin [[https://github.com/oantolin/orderless#style-dispatchers][style dispatchers]] for more finegrained filtering, which Doom has some builtin [[https://github.com/oantolin/orderless#style-dispatchers][style dispatchers]] for more finegrained filtering, which
you can use to further specify each space separated input in the following ways: you can use to further specify each space separated input in the following ways:
| Input | Description | | Input | Description |
|------------------+--------------------------------------------| |------------------+----------------------------------------------|
| =!foo= | match without literal input =foo= | | =!foo= | match without literal input =foo= |
| =`bar= or =bar`= | match input =bar= as an initialism | | =%foo= or =foo%= | perform ~char-fold-to-regexp~ on input =foo= |
| ==baz= or =baz== | match only with literal input =baz= | | =`foo= or =foo`= | match input =foo= as an initialism |
| =~qux= or =qux~= | match input =qux= with fuzzy/flex matching | | ==foo= or =foo== | match only with literal input =foo= |
| =~foo= or =foo~= | match input =foo= with fuzzy/flex matching |
* Configuration * Configuration
If you want to further configure this module, here are some good places to start: If you want to further configure this module, here are some good places to start:
** Vertico
+ Vertico provides several [[https://github.com/minad/vertico#extensions][extentions]] that can be used to extend it's interface Vertico provides several [[https://github.com/minad/vertico#extensions][extentions]] that can be used to extend it's interface
+ You can add more Marginalia annotation levels and change the existing ones by ** Consult
Much of the behaviour of Consult commands can be changed with
~consult-customize~. The =vertico= module already does this, if you want to
override the module's modifications, do:
#+begin_src emacs-lisp
(setq consult--read-config nil)
(consult-customize
;...
)
#+end_src
If you are changing the preview key (set to =C-SPC=), remember to change the
binding on ~vertico-map~ as well, as the binding there gets previews to work to
an extent on non-consult commands as well.
** Marginalia
You can add more Marginalia annotation levels and change the existing ones by
editing ~marginalia-annotator-registry~ editing ~marginalia-annotator-registry~
+ You can change the available commands in Embark for category ~$cat~ by editing ** Embark
You can change the available commands in Embark for category ~$cat~ by editing
~embark-$cat-map~, and even add new categories. Note that you add categories ~embark-$cat-map~, and even add new categories. Note that you add categories
by defining them [[https://github.com/minad/marginalia/#adding-custom-annotators-or-classifiers][through marginalia]], and embark picks up on them. by defining them [[https://github.com/minad/marginalia/#adding-custom-annotators-or-classifiers][through marginalia]], and embark picks up on them.

View file

@ -0,0 +1,8 @@
;;; completion/vertico/autoload/magit.el -*- lexical-binding: t; -*-
;;;###if (featurep! :tools magit)
;;;###autoload
(defun +vertico/embark-magit-status (file)
"Run `magit-status` on repo containing the embark target."
(interactive "GFile: ")
(magit-status (locate-dominating-file file ".git")))

View file

@ -40,20 +40,19 @@ orderless."
(setq deactivate-mark t) (setq deactivate-mark t)
(let* ((project-root (or (doom-project-root) default-directory)) (let* ((project-root (or (doom-project-root) default-directory))
(directory (or in project-root)) (directory (or in project-root))
(args (consult-ripgrep-args
(split-string (concat "rg "
(string-trim (if all-files "-uu ")
(concat (if all-files "-uu") (unless recursive "--maxdepth 1 ")
(unless recursive "--maxdepth 1") "--line-buffered --color=never --max-columns=1000 "
"--null --line-buffered --color=always --max-columns=500 --no-heading --line-number --smart-case" "--path-separator / --smart-case --no-heading --line-number "
" --hidden -g !.git " "--hidden -g !.git "
(mapconcat #'shell-quote-argument args " "))) (mapconcat #'shell-quote-argument args " ")
" ")) "."))
(prompt (if (stringp prompt) (string-trim prompt) "Search")) (prompt (if (stringp prompt) (string-trim prompt) "Search"))
(query (or query (query (or query
(when (doom-region-active-p) (when (doom-region-active-p)
(rxt-quote-pcre (doom-thing-at-point-or-region))))) (regexp-quote (doom-thing-at-point-or-region)))))
(ripgrep-command (string-join `("rg" ,@args "." "-e ARG OPTS" ) " "))
(consult-async-split-style consult-async-split-style) (consult-async-split-style consult-async-split-style)
(consult-async-split-styles-alist consult-async-split-styles-alist)) (consult-async-split-styles-alist consult-async-split-styles-alist))
;; Change the split style if the initial query contains the separator. ;; Change the split style if the initial query contains the separator.
@ -74,7 +73,7 @@ orderless."
"%") "%")
:type perl) :type perl)
consult-async-split-style 'perlalt)))))) consult-async-split-style 'perlalt))))))
(consult--grep prompt ripgrep-command directory query))) (consult--grep prompt #'consult--ripgrep-builder directory query)))
;;;###autoload ;;;###autoload
(defun +vertico/project-search (&optional arg initial-query directory) (defun +vertico/project-search (&optional arg initial-query directory)
@ -96,30 +95,13 @@ If ARG (universal argument), include all files, even hidden or compressed ones."
(interactive) (interactive)
(consult-line (thing-at-point 'symbol))) (consult-line (thing-at-point 'symbol)))
;;;###autoload
(defun +vertico/backward-updir ()
"Delete char before or go up directory for file cagetory vertico buffers."
(interactive)
(let ((metadata (completion-metadata (minibuffer-contents)
minibuffer-completion-table
minibuffer-completion-predicate)))
(if (and (eq (char-before) ?/)
(eq (completion-metadata-get metadata 'category) 'file))
(let ((new-path (minibuffer-contents)))
(delete-region (minibuffer-prompt-end) (point-max))
(insert (abbreviate-file-name
(file-name-directory
(directory-file-name
(expand-file-name new-path))))))
(call-interactively 'backward-delete-char))))
;;;###autoload ;;;###autoload
(defun +vertico-embark-target-package-fn () (defun +vertico-embark-target-package-fn ()
"Targets Doom's package! statements and returns the package name" "Targets Doom's package! statements and returns the package name"
(when (or (derived-mode-p 'emacs-lisp-mode) (derived-mode-p 'org-mode)) (when (or (derived-mode-p 'emacs-lisp-mode) (derived-mode-p 'org-mode))
(save-excursion (save-excursion
(search-backward "(") (when (and (search-backward "(" nil t)
(when (looking-at "(\\s-*package!\\s-*\\(\\(\\sw\\|\\s_\\)+\\)\\s-*") (looking-at "(\\s-*package!\\s-*\\(\\(\\sw\\|\\s_\\)+\\)\\s-*"))
(let ((pkg (match-string 1))) (let ((pkg (match-string 1)))
(set-text-properties 0 (length pkg) nil pkg) (set-text-properties 0 (length pkg) nil pkg)
`(package . ,pkg)))))) `(package . ,pkg))))))
@ -152,20 +134,6 @@ Supports exporting consult-grep to wgrep, file to wdeired, and consult-location
(let ((embark-quit-after-action nil)) (let ((embark-quit-after-action nil))
(embark-dwim))))) (embark-dwim)))))
;;;###autoload
(defun +vertico/next-candidate-preview (&optional n)
"Go forward N candidates and preivew"
(interactive)
(vertico-next (or n 1))
(+vertico/embark-preview))
;;;###autoload
(defun +vertico/previous-candidate-preview (&optional n)
"Go backward N candidates and preivew"
(interactive)
(vertico-previous (or n 1))
(+vertico/embark-preview))
(defvar +vertico/find-file-in--history nil) (defvar +vertico/find-file-in--history nil)
;;;###autoload ;;;###autoload
(defun +vertico/find-file-in (&optional dir initial) (defun +vertico/find-file-in (&optional dir initial)
@ -175,15 +143,12 @@ If INITIAL is non-nil, use as initial input."
(require 'consult) (require 'consult)
(let* ((default-directory (or dir default-directory)) (let* ((default-directory (or dir default-directory))
(prompt-dir (consult--directory-prompt "Find" default-directory)) (prompt-dir (consult--directory-prompt "Find" default-directory))
(cmd (split-string-and-unquote consult-find-command " ")) (cmd (split-string-and-unquote +vertico-consult-fd-args " ")))
(cmd (remove "OPTS" cmd))
(cmd (remove "ARG" cmd)))
(find-file (find-file
(consult--read (consult--read
(split-string (cdr (apply #'doom-call-process cmd)) "\n" t) (split-string (cdr (apply #'doom-call-process cmd)) "\n" t)
:prompt default-directory :prompt default-directory
:sort nil :sort nil
:require-match t
:initial (if initial (shell-quote-argument initial)) :initial (if initial (shell-quote-argument initial))
:add-history (thing-at-point 'filename) :add-history (thing-at-point 'filename)
:category 'file :category 'file
@ -194,6 +159,7 @@ If INITIAL is non-nil, use as initial input."
"Go to an entry in evil's (or better-jumper's) jumplist." "Go to an entry in evil's (or better-jumper's) jumplist."
(interactive (interactive
(let (buffers) (let (buffers)
(require 'consult)
(unwind-protect (unwind-protect
(list (list
(consult--read (consult--read
@ -236,7 +202,7 @@ If INITIAL is non-nil, use as initial input."
(forward-line (string-to-number line))))) (forward-line (string-to-number line)))))
;;;###autoload ;;;###autoload
(defun +vertico/embark-which-key-indicator () (defun +vertico-embark-which-key-indicator ()
"An embark indicator that displays keymaps using which-key. "An embark indicator that displays keymaps using which-key.
The which-key help message will show the type and value of the The which-key help message will show the type and value of the
current target followed by an ellipsis if there are further current target followed by an ellipsis if there are further
@ -261,7 +227,7 @@ targets."
(let ((idx vertico--index)) (let ((idx vertico--index))
(unless (get-text-property 0 'consult--crm-selected (nth vertico--index vertico--candidates)) (unless (get-text-property 0 'consult--crm-selected (nth vertico--index vertico--candidates))
(setq idx (1+ idx))) (setq idx (1+ idx)))
(run-at-time 0 nil (cmd! (vertico--goto idx) (vertico--exhibit)))) (run-at-time 0 nil (cmd! (vertico--goto idx) (vertico--exhibit))))
(vertico-exit)) (vertico-exit))
;;;###autoload ;;;###autoload
@ -270,3 +236,46 @@ targets."
(interactive) (interactive)
(run-at-time 0 nil #'vertico-exit) (run-at-time 0 nil #'vertico-exit)
(vertico-exit)) (vertico-exit))
;;;###autoload
(defun +vertico--consult--fd-builder (input)
(pcase-let* ((cmd (split-string-and-unquote +vertico-consult-fd-args))
(`(,arg . ,opts) (consult--command-split input))
(`(,re . ,hl) (funcall consult--regexp-compiler
arg 'extended)))
(when re
(list :command (append cmd
(list (consult--join-regexps re 'extended))
opts)
:highlight hl))))
(autoload #'consult--directory-prompt "consult")
;;;###autoload
(defun +vertico/consult-fd (&optional dir initial)
(interactive "P")
(if doom-projectile-fd-binary
(let* ((prompt-dir (consult--directory-prompt "Fd" dir))
(default-directory (cdr prompt-dir)))
(find-file (consult--find (car prompt-dir) #'+vertico--consult--fd-builder initial)))
(consult-find dir initial)))
;;;###autoload
(defun +vertico-embark-vertico-indicator ()
"An embark indicator that colorizes the vertico candidate differently on act"
(let ((fr face-remapping-alist))
(lambda (&optional keymap _targets prefix)
(when (bound-and-true-p vertico--input)
(setq-local face-remapping-alist
(if keymap
(cons '(vertico-current . embark-target) fr)
fr))))))
;;;###autoload
(defun +vertico-basic-remote-try-completion (string table pred point)
(and (vertico--remote-p string)
(completion-basic-try-completion string table pred point)))
;;;###autoload
(defun +vertico-basic-remote-all-completions (string table pred point)
(and (vertico--remote-p string)
(completion-basic-all-completions string table pred point)))

View file

@ -7,6 +7,8 @@ The completion/vertico module uses the orderless completion style by default,
but this returns too broad a candidate set for company completion. This variable but this returns too broad a candidate set for company completion. This variable
overrides `completion-styles' during company completion sessions.") overrides `completion-styles' during company completion sessions.")
(defvar +vertico-consult-fd-args nil
"Shell command and arguments the vertico module uses for fd.")
;; ;;
;;; Packages ;;; Packages
@ -26,7 +28,7 @@ overrides `completion-styles' during company completion sessions.")
;; Cleans up path when moving directories with shadowed paths syntax, e.g. ;; Cleans up path when moving directories with shadowed paths syntax, e.g.
;; cleans ~/foo/bar/// to /, and ~/foo/bar/~/ to ~/. ;; cleans ~/foo/bar/// to /, and ~/foo/bar/~/ to ~/.
(add-hook 'rfn-eshadow-update-overlay-hook #'vertico-directory-tidy) (add-hook 'rfn-eshadow-update-overlay-hook #'vertico-directory-tidy)
(map! :map vertico-map [backspace] #'+vertico/backward-updir)) (map! :map vertico-map [backspace] #'vertico-directory-delete-char))
(use-package! orderless (use-package! orderless
@ -41,6 +43,9 @@ overrides `completion-styles' during company completion sessions.")
((string= "!" pattern) `(orderless-literal . "")) ((string= "!" pattern) `(orderless-literal . ""))
;; Without literal ;; Without literal
((string-prefix-p "!" pattern) `(orderless-without-literal . ,(substring pattern 1))) ((string-prefix-p "!" pattern) `(orderless-without-literal . ,(substring pattern 1)))
;; Character folding
((string-prefix-p "%" pattern) `(char-fold-to-regexp . ,(substring pattern 1)))
((string-suffix-p "%" pattern) `(char-fold-to-regexp . ,(substring pattern 0 -1)))
;; Initialism matching ;; Initialism matching
((string-prefix-p "`" pattern) `(orderless-initialism . ,(substring pattern 1))) ((string-prefix-p "`" pattern) `(orderless-initialism . ,(substring pattern 1)))
((string-suffix-p "`" pattern) `(orderless-initialism . ,(substring pattern 0 -1))) ((string-suffix-p "`" pattern) `(orderless-initialism . ,(substring pattern 0 -1)))
@ -50,11 +55,17 @@ overrides `completion-styles' during company completion sessions.")
;; Flex matching ;; Flex matching
((string-prefix-p "~" pattern) `(orderless-flex . ,(substring pattern 1))) ((string-prefix-p "~" pattern) `(orderless-flex . ,(substring pattern 1)))
((string-suffix-p "~" pattern) `(orderless-flex . ,(substring pattern 0 -1))))) ((string-suffix-p "~" pattern) `(orderless-flex . ,(substring pattern 0 -1)))))
(add-to-list
'completion-styles-alist
'(+vertico-basic-remote
+vertico-basic-remote-try-completion
+vertico-basic-remote-all-completions
"Use basic completion on remote files only"))
(setq completion-styles '(orderless) (setq completion-styles '(orderless)
completion-category-defaults nil completion-category-defaults nil
;; note that despite override in the name orderless can still be used in ;; note that despite override in the name orderless can still be used in
;; find-file etc. ;; find-file etc.
completion-category-overrides '((file (styles . (orderless partial-completion)))) completion-category-overrides '((file (styles +vertico-basic-remote orderless partial-completion)))
orderless-style-dispatchers '(+vertico-orderless-dispatch) orderless-style-dispatchers '(+vertico-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
@ -82,7 +93,6 @@ overrides `completion-styles' during company completion sessions.")
[remap persp-switch-to-buffer] #'+vertico/switch-workspace-buffer) [remap persp-switch-to-buffer] #'+vertico/switch-workspace-buffer)
(advice-add #'completing-read-multiple :override #'consult-completing-read-multiple) (advice-add #'completing-read-multiple :override #'consult-completing-read-multiple)
(advice-add #'multi-occur :override #'consult-multi-occur) (advice-add #'multi-occur :override #'consult-multi-occur)
(setq prefix-help-command #'embark-prefix-help-command)
:config :config
(setq consult-project-root-function #'doom-project-root (setq consult-project-root-function #'doom-project-root
consult-narrow-key "<" consult-narrow-key "<"
@ -91,12 +101,13 @@ overrides `completion-styles' during company completion sessions.")
consult-async-refresh-delay 0.15 consult-async-refresh-delay 0.15
consult-async-input-throttle 0.2 consult-async-input-throttle 0.2
consult-async-input-debounce 0.1) consult-async-input-debounce 0.1)
(unless +vertico-consult-fd-args
(when doom-projectile-fd-binary (setq +vertico-consult-fd-args
(setq consult-find-command (if doom-projectile-fd-binary
(format "%s -i -H -E .git --regex %s ARG OPTS" (format "%s --color=never -i -H -E .git --regex %s"
doom-projectile-fd-binary doom-projectile-fd-binary
(if IS-WINDOWS "--path-separator=/" "")))) (if IS-WINDOWS "--path-separator=/" ""))
consult-find-args)))
(consult-customize (consult-customize
consult-ripgrep consult-git-grep consult-grep consult-ripgrep consult-git-grep consult-grep
@ -106,12 +117,10 @@ overrides `completion-styles' during company completion sessions.")
+default/search-cwd +default/search-other-cwd +default/search-cwd +default/search-other-cwd
+default/search-notes-for-symbol-at-point +default/search-notes-for-symbol-at-point
consult--source-file consult--source-project-file consult--source-bookmark consult--source-file consult--source-project-file consult--source-bookmark
:preview-key (list (kbd "C-SPC") (kbd "C-M-j") (kbd "C-M-k"))) :preview-key (kbd "C-SPC"))
(consult-customize (consult-customize
consult-theme consult-theme
:preview-key :preview-key (list (kbd "C-SPC") :debounce 0.5 'any))
(list (kbd "C-SPC") (kbd "C-M-j") (kbd "C-M-k")
:debounce 0.5 'any))
(after! org (after! org
(defvar +vertico--consult-org-source (defvar +vertico--consult-org-source
`(:name "Org" `(:name "Org"
@ -134,6 +143,8 @@ overrides `completion-styles' during company completion sessions.")
(use-package! embark (use-package! embark
:defer t :defer t
:init :init
(setq which-key-use-C-h-commands nil
prefix-help-command #'embark-prefix-help-command)
(map! [remap describe-bindings] #'embark-bindings (map! [remap describe-bindings] #'embark-bindings
"C-;" #'embark-act ; to be moved to :config default if accepted "C-;" #'embark-act ; to be moved to :config default if accepted
(:map minibuffer-local-map (:map minibuffer-local-map
@ -144,8 +155,8 @@ overrides `completion-styles' during company completion sessions.")
:desc "Actions" "a" #'embark-act)) ; to be moved to :config default if accepted :desc "Actions" "a" #'embark-act)) ; to be moved to :config default if accepted
:config :config
(set-popup-rule! "^\\*Embark Export Grep" :size 0.35 :ttl 0 :quit nil) (set-popup-rule! "^\\*Embark Export Grep" :size 0.35 :ttl 0 :quit nil)
(cl-nsubstitute #'+vertico-embark-which-key-indicator #'embark-mixed-indicator embark-indicators)
(setq embark-indicator #'+vertico/embark-which-key-indicator) (add-to-list 'embark-indicators #'+vertico-embark-vertico-indicator)
;; add the package! target finder before the file target finder, ;; add the package! target finder before the file target finder,
;; so we don't get a false positive match. ;; so we don't get a false positive match.
(let ((pos (or (cl-position (let ((pos (or (cl-position
@ -156,15 +167,19 @@ overrides `completion-styles' during company completion sessions.")
cons cons
'+vertico-embark-target-package-fn '+vertico-embark-target-package-fn
(nthcdr pos embark-target-finders))) (nthcdr pos embark-target-finders)))
(setq embark-package-map (make-sparse-keymap)) (embark-define-keymap +vertico/embark-doom-package-map
"Keymap for Embark package actions for packages installed by Doom."
("h" doom/help-packages)
("b" doom/bump-package)
("c" doom/help-package-config)
("u" doom/help-package-homepage))
(setf (alist-get 'package embark-keymap-alist) #'+vertico/embark-doom-package-map)
(map! (:map embark-file-map (map! (:map embark-file-map
:desc "Open target with sudo" "s" #'doom/sudo-find-file :desc "Open target with sudo" "s" #'doom/sudo-find-file
:desc "Open in new workspace" "TAB" #'+vertico/embark-open-in-new-workspace) (:when (featurep! :tools magit)
(:map embark-package-map :desc "Open magit-status of target" "g" #'+vertico/embark-magit-status)
"h" #'doom/help-packages (:when (featurep! :ui workspaces)
"b" #'doom/bump-package :desc "Open in new workspace" "TAB" #'+vertico/embark-open-in-new-workspace))))
"c" #'doom/help-package-config
"u" #'doom/help-package-homepage)))
(use-package! marginalia (use-package! marginalia

View file

@ -0,0 +1,11 @@
;;; completion/vertico/doctor.el -*- lexical-binding: t; -*-
(require 'consult)
(unless (consult--grep-lookahead-p "grep" "-P")
(warn! "The installed grep binary was not built with support for PCRE lookaheads.
Some advanced consult filtering features will not work as a result, see the module readme."))
(unless (consult--grep-lookahead-p "rg" "-P")
(warn! "The installed ripgrep binary was not built with support for PCRE lookaheads.
Some advanced consult filtering features will not work as a result, see the module readme."))

View file

@ -4,22 +4,20 @@
(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 "9de6709cddc09740d23d24fb425fa3c174d0e956") :pin "81a4b35f8d11dfad56de1727ee9bdd3b4461d07c")
(package! orderless :pin "1e84120a28525ccb47b602fc19b7afbeffbbe502") (package! orderless :pin "62f71c34baca0b7d0adeab4a1c07d85ffcee80d9")
(package! consult :pin "69bbd213dc8a98abe94a4f5b1920e3d689d31caa") (package! consult :pin "a07ca383318cdce6935a370f1d17687ba9f225c3")
(when (featurep! :checkers syntax) (when (featurep! :checkers syntax)
(package! consult-flycheck :pin "92b259e6a8ebe6439f67d3d7ffa44b7e64b76478")) (package! consult-flycheck :pin "92b259e6a8ebe6439f67d3d7ffa44b7e64b76478"))
(package! embark :pin "1a7e6b556142216fa5f9b897bd5eca73968f3c49") (package! embark :pin "3a90a3e3c6cd035503d0c9de5c22875028e6da00")
(package! embark-consult :pin "1a7e6b556142216fa5f9b897bd5eca73968f3c49") (package! embark-consult :pin "3a90a3e3c6cd035503d0c9de5c22875028e6da00")
(package! marginalia :pin "11235445365c6ab119acabe91828e9182097ece7") (package! marginalia :pin "cb1d3ba604dda17d8d44e7355ad76a1651830a30")
(package! wgrep :pin "f9687c28bbc2e84f87a479b6ce04407bb97cfb23") (package! wgrep :pin "f9687c28bbc2e84f87a479b6ce04407bb97cfb23")
(when (featurep! +icons) (when (featurep! +icons)
(package! all-the-icons-completion (package! all-the-icons-completion :pin "96500418541b7376cd0b3e4583b9509c0dd92b27"))
:recipe (:host github :repo "iyefrat/all-the-icons-completion")
:pin "d1d4b2f0dfbfa94d33fe50e8089c06601adfe674"))

View file

@ -40,9 +40,7 @@
:desc "Find type definition" "t" #'+lookup/type-definition :desc "Find type definition" "t" #'+lookup/type-definition
:desc "Delete trailing whitespace" "w" #'delete-trailing-whitespace :desc "Delete trailing whitespace" "w" #'delete-trailing-whitespace
:desc "Delete trailing newlines" "W" #'doom/delete-trailing-newlines :desc "Delete trailing newlines" "W" #'doom/delete-trailing-newlines
:desc "List errors" "x" #'flymake-show-diagnostics-buffer :desc "List errors" "x" #'+default/diagnostics
(:when (featurep! :checkers syntax)
:desc "List errors" "x" #'flycheck-list-errors)
(:when (and (featurep! :tools lsp) (not (featurep! :tools lsp +eglot))) (:when (and (featurep! :tools lsp) (not (featurep! :tools lsp +eglot)))
:desc "LSP Code actions" "a" #'lsp-execute-code-action :desc "LSP Code actions" "a" #'lsp-execute-code-action
:desc "LSP Organize imports" "o" #'lsp-organize-imports :desc "LSP Organize imports" "o" #'lsp-organize-imports
@ -66,7 +64,9 @@
(:when (featurep! :tools lsp +eglot) (:when (featurep! :tools lsp +eglot)
:desc "LSP Execute code action" "a" #'eglot-code-actions :desc "LSP Execute code action" "a" #'eglot-code-actions
:desc "LSP Rename" "r" #'eglot-rename :desc "LSP Rename" "r" #'eglot-rename
:desc "LSP Find declaration" "j" #'eglot-find-declaration)) :desc "LSP Find declaration" "j" #'eglot-find-declaration
(:when (featurep! :completion vertico)
:desc "Jump to symbol in current workspace" "j" #'consult-eglot-symbols)))
;;; <leader> f --- file ;;; <leader> f --- file
(:prefix-map ("f" . "file") (:prefix-map ("f" . "file")

View file

@ -209,11 +209,9 @@
"M-RET" #'vertico-exit-input "M-RET" #'vertico-exit-input
"C-SPC" #'+vertico/embark-preview "C-SPC" #'+vertico/embark-preview
"C-j" #'vertico-next "C-j" #'vertico-next
"C-M-j" #'+vertico/next-candidate-preview "C-M-j" #'vertico-next-group
"C-S-j" #'vertico-next-group
"C-k" #'vertico-previous "C-k" #'vertico-previous
"C-M-k" #'+vertico/previous-candidate-preview "C-M-k" #'vertico-previous-group)))
"C-S-k" #'vertico-previous-group)))
;;; :ui ;;; :ui
@ -398,7 +396,9 @@
(:when (featurep! :tools lsp +eglot) (:when (featurep! :tools lsp +eglot)
:desc "LSP Execute code action" "a" #'eglot-code-actions :desc "LSP Execute code action" "a" #'eglot-code-actions
:desc "LSP Rename" "r" #'eglot-rename :desc "LSP Rename" "r" #'eglot-rename
:desc "LSP Find declaration" "j" #'eglot-find-declaration) :desc "LSP Find declaration" "j" #'eglot-find-declaration
(:when (featurep! :completion vertico)
:desc "Jump to symbol in current workspace" "j" #'consult-eglot-symbols))
:desc "Compile" "c" #'compile :desc "Compile" "c" #'compile
:desc "Recompile" "C" #'recompile :desc "Recompile" "C" #'recompile
:desc "Jump to definition" "d" #'+lookup/definition :desc "Jump to definition" "d" #'+lookup/definition
@ -412,9 +412,7 @@
:desc "Find type definition" "t" #'+lookup/type-definition :desc "Find type definition" "t" #'+lookup/type-definition
:desc "Delete trailing whitespace" "w" #'delete-trailing-whitespace :desc "Delete trailing whitespace" "w" #'delete-trailing-whitespace
:desc "Delete trailing newlines" "W" #'doom/delete-trailing-newlines :desc "Delete trailing newlines" "W" #'doom/delete-trailing-newlines
:desc "List errors" "x" #'flymake-show-diagnostics-buffer :desc "List errors" "x" #'+default/diagnostics)
(:when (featurep! :checkers syntax)
:desc "List errors" "x" #'flycheck-list-errors))
;;; <leader> f --- file ;;; <leader> f --- file
(:prefix-map ("f" . "file") (:prefix-map ("f" . "file")

View file

@ -44,3 +44,22 @@ If ARG (universal argument), runs `compile' from the current directory."
(while (server-running-p) (while (server-running-p)
(sleep-for 1)) (sleep-for 1))
(server-start)) (server-start))
;;;###autoload
(defun +default/diagnostics (&rest arg)
"List diagnostics for the current buffer/project.
If the the vertico and lsp modules are active, list lsp diagnostics for the
current project. Otherwise list them for the current buffer"
(interactive)
(cond ((and (featurep! :completion vertico)
(featurep! :tools lsp)
(bound-and-true-p lsp-mode))
(consult-lsp-diagnostics arg))
((and (featurep! :checkers syntax)
(bound-and-true-p flycheck-mode))
(flycheck-list-errors))
((bound-and-true-p flymake-mode)
(flymake-show-diagnostics-buffer))
(t
(user-error "No diagnostics backend detected. Enable flycheck or \
flymake, or set up lsp-mode if applicable (see :lang lsp)"))))

View file

@ -78,7 +78,7 @@
(evil-ex-define-cmd "make" #'+evil:make) (evil-ex-define-cmd "make" #'+evil:make)
(evil-ex-define-cmd "mk" #'+evil:make) ; convenience alias (evil-ex-define-cmd "mk" #'+evil:make) ; convenience alias
(evil-ex-define-cmd "debug" #'+debugger/start) (evil-ex-define-cmd "debug" #'+debugger/start)
(evil-ex-define-cmd "er[rors]" #'flycheck-list-errors) (evil-ex-define-cmd "er[rors]" #'+default/diagnostics)
;;; File operations ;;; File operations
(evil-ex-define-cmd "cp" #'+evil:copy-this-file) (evil-ex-define-cmd "cp" #'+evil:copy-this-file)

View file

@ -9,4 +9,4 @@
(when (featurep! :completion helm) (when (featurep! :completion helm)
(package! helm-notmuch :pin "97a01497e079a7b6505987e9feba6b603bbec288")) (package! helm-notmuch :pin "97a01497e079a7b6505987e9feba6b603bbec288"))
(when (featurep! :completion vertico) (when (featurep! :completion vertico)
(package! consult-notmuch :pin "67cf219fcce211237347a783ce6982402341d5fd")) (package! consult-notmuch :pin "a5133b9e1f19b6d51e51dd5c5e3a4f236ca29b57"))

View file

@ -48,3 +48,10 @@ server getting expensively restarted when reverting buffers."
(+lsp-optimization-mode -1)))) (+lsp-optimization-mode -1))))
server))) server)))
(funcall fn server)))) (funcall fn server))))
(use-package! consult-eglot
:defer t
:when (featurep! :completion vertico)
:init
(map! :map eglot-mode-map [remap xref-find-apropos] #'consult-eglot-symbols))

View file

@ -216,3 +216,10 @@ instead is more sensible."
(use-package! lsp-ivy (use-package! lsp-ivy
:when (featurep! :completion ivy) :when (featurep! :completion ivy)
:commands lsp-ivy-workspace-symbol lsp-ivy-global-workspace-symbol) :commands lsp-ivy-workspace-symbol lsp-ivy-global-workspace-symbol)
(use-package! consult-lsp
:defer t
:when (featurep! :completion vertico)
:init
(map! :map lsp-mode-map [remap xref-find-apropos] #'consult-lsp-symbols))

View file

@ -2,7 +2,10 @@
;;; tools/lsp/packages.el ;;; tools/lsp/packages.el
(if (featurep! +eglot) (if (featurep! +eglot)
(package! eglot :pin "c17bdf6c98d6bf0f1a85f1175556e1038654402f") (progn
(package! eglot :pin "c17bdf6c98d6bf0f1a85f1175556e1038654402f")
(when (featurep! :completion vertico)
(package! consult-eglot :pin "a6aeb6fa078cc7ea6537793868f606b55ac63088")))
(package! lsp-mode :pin "82fa7743602e9a6366ecd128efcd620ecc97fcf4") (package! lsp-mode :pin "82fa7743602e9a6366ecd128efcd620ecc97fcf4")
(package! lsp-ui :pin "b625f3cb5e88559ab99bec58f7a14272edb296bc") (package! lsp-ui :pin "b625f3cb5e88559ab99bec58f7a14272edb296bc")
(when (featurep! :completion ivy) (when (featurep! :completion ivy)