2022-03-28 15:03:21 +02:00
#+title : :completion vertico
#+subtitle : Tomorrow's search engine
#+created : July 25, 2021
#+since : 21.12.0 (#4664)
2021-10-16 01:21:31 +02:00
* Description :unfold:
2021-07-11 20:01:27 +03:00
This module enhances the Emacs search and completion experience, and also
provides a united interface for project search and replace, powered by [[https://github.com/BurntSushi/ripgrep/ ][ripgrep ]].
2021-02-16 16:51:03 -06:00
2021-07-11 20:01:27 +03:00
It does this with several modular packages focused on enhancing the built-in
~completing-read~ interface, rather than replacing it with a parallel ecosystem
2022-09-26 02:19:42 +08:00
like [[doom-package:ivy ]] and [[doom-package:helm ]] do. The primary packages are:
2021-07-11 20:01:27 +03:00
2021-10-16 01:21:31 +02:00
- Vertico, which provides the vertical completion user interface
- Consult, which provides a suite of useful commands using ~completing-read~
- Embark, which provides a set of minibuffer actions
- Marginalia, which provides annotations to completion candidates
- Orderless, which provides better filtering methods
2021-07-11 20:01:27 +03:00
** Maintainers
2021-10-16 01:21:31 +02:00
- [[doom-user: ][@iyefrat ]]
[[doom-contrib-maintainer: ][Become a maintainer? ]]
** Module flags
2022-08-08 14:54:48 +02:00
- +childframe ::
Display completion candidates in a [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Child-Frames.html ][child frame ]] rather than an overlay or
tooltip. *Requires GUI Emacs.*
2021-10-16 01:21:31 +02:00
- +icons ::
Add icons to =file= and =buffer= category completion selections.
** Packages
2022-09-26 02:19:42 +08:00
- [[doom-package:all-the-icons-completion ]] if [[doom-module:+icons ]]
- [[doom-package:consult ]]
- [[doom-package:consult-flycheck ]] if [[doom-module::checkers syntax ]]
- [[doom-package:embark ]]
- [[doom-package:embark-consult ]]
- [[doom-package:marginalia ]]
- [[doom-package:orderless ]]
- [[doom-package:vertico ]]
- [[doom-package:vertico-posframe ]] if [[doom-module:+childframe ]]
- [[doom-package:wgrep ]]
2021-10-16 01:21:31 +02:00
** Hacks
/No hacks documented for this module./
** TODO Changelog
# This section will be machine generated. Don't edit it by hand.
/This module does not have a changelog yet./
* Installation
[[id:01cffea4-3329-45e2-a892-95a384ab2338 ][Enable this module in your ~doom!~ block. ]]
This module has only one requirement: [[https://github.com/BurntSushi/ripgrep ][Ripgrep ]] (built with [[https://www.pcre.org/ ][PCRE ]] support; run ~$
doom doctor~ to determine if your build meets this requirement), which is a hard
dependency of Doom itself, so you should already have it installed.
Otherwise, Consult (a plugin this module installs) provides many commands to
interface with a variety of programs from [[https://github.com/junegunn/fzf ][fzf ]] to [[https://kapeli.com/dash ][Dash docsets ]] to [[https://www.passwordstore.org/ ][pass ]] and /much/
more. These programs are optional for this module, but must be installed if you
intend to use their associated Helm command or plugin.
* TODO Usage
#+begin_quote
🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module: ][Complete it? ]]
#+end_quote
2021-04-10 14:44:27 +03:00
2021-06-09 18:14:36 +03:00
The packages in this module modify and use the built-in ~completing-read~
function, which is used by any function that requires completion. Due to this
the full scope of these packages is too large to cover here and you are
encouraged to go and read their excellent documentation. We will detail
Doom-specific additions:
2021-04-10 14:44:27 +03:00
2021-07-11 20:01:27 +03:00
** Vertico keybindings
When in an active Vertico completion session, the following doom added
keybindings are available:
2022-08-03 03:23:34 +02:00
| Keybind | Description |
|-------------------+----------------------------------------------------------------|
| [[kbd:][C-k]] | (evil) Go to previous candidate |
| [[kbd:][C-j]] | (evil) Go to next candidate |
| [[kbd:][C-M-k]] | (evil) Go to previous group |
| [[kbd:][C-M-j]] | (evil) Go to next group |
| [[kbd:][C-;]] or [[kbd:][<leader> a]] | Open an ~embark-act~ menu to chose a useful action |
| [[kbd:][C-c C-;]] | export the current candidate list to a buffer |
| [[kbd:][C-c C-l]] | ~embark-collect~ the current candidate list (collect verbatim) |
| [[kbd:][C-SPC]] | Preview the current candidate |
2021-07-11 20:01:27 +03:00
~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
2021-10-16 01:21:31 +02:00
that you can press [[kbd: ][C-h ]] instead of choosing a command to filter through the
2021-07-11 20:01:27 +03:00
options with a Vertico buffer, that also has slightly more detailed descriptions
due to Marginalia annotations.
2021-04-10 14:44:27 +03:00
** Jump-to navigation
This module provides an interface to navigate within a project using
2022-09-26 02:19:42 +08:00
[[doom-package:projectile ]]:
2021-04-10 14:44:27 +03:00
2021-07-09 20:16:11 +03:00
https://assets.doomemacs.org/completion/vertico/projectile.png
2021-04-10 14:44:27 +03:00
2021-10-16 01:21:31 +02:00
| Keybind | Description |
|------------------+-------------------------------------|
| [[kbd:][SPC p f]], [[kbd:][SPC SPC]] | Jump to file in project |
| [[kbd:][SPC f f]], [[kbd:][SPC .]] | Jump to file from current directory |
| [[kbd:][SPC s i]] | Jump to symbol in file |
2021-04-10 14:44:27 +03:00
** Project search & replace
This module provides interactive text search and replace using ripgrep.
2021-10-16 01:21:31 +02:00
| Keybind | Description |
|---------+--------------------------|
| [[kbd:][<leader> s p]] | Search project |
| [[kbd:][<leader> s P]] | Search another project |
| [[kbd:][<leader> s d]] | Search this directory |
| [[kbd:][<leader> s D]] | Search another directory |
2021-04-10 14:44:27 +03:00
2021-07-09 20:16:11 +03:00
https://assets.doomemacs.org/completion/vertico/search.png
2021-04-10 14:44:27 +03:00
2021-10-16 01:21:31 +02:00
Prefixing these keys with the universal argument ([[kbd: ][SPC u ]] for evil users; [[kbd: ][C-u ]]
2021-04-10 14:44:27 +03:00
otherwise) changes the behavior of these commands, instructing the underlying
search engine to include ignored files.
This module also provides Ex Commands for evil users:
2021-10-16 01:21:31 +02:00
| Ex command | Description |
|----------------------+----------------------------------------------------------------|
2021-04-10 14:44:27 +03:00
| ~:pg[rep][!] [QUERY]~ | Search project (if ~!~, include hidden files) |
| ~:pg[rep]d[!] [QUERY]~ | Search from current directory (if ~!~, don't search recursively) |
2021-10-16 01:21:31 +02:00
The optional ~!~ is equivalent to the universal argument for the previous
2021-04-10 14:44:27 +03:00
commands.
-----
2021-07-11 20:01:27 +03:00
On top of the usual Vertico keybindings, search commands also offer support for
2021-10-16 01:21:31 +02:00
exporting the current candidate list to an editable buffer [[kbd: ][C-c C-e ]]. After
editing the changes can be committed with [[kbd: ][C-c C-c ]] and aborted with [[kbd: ][C-c C-k ]]
2022-09-26 02:19:42 +08:00
(alternatively [[kbd: ][ZZ ]] and [[kbd: ][ZQ ]], for evil users). It uses [[doom-package:wgrep ]] for grep searches,
[[doom-package:wdired ]] for file searches, and =occur= for buffer searches.
2021-04-10 14:44:27 +03:00
2021-07-09 20:16:11 +03:00
https://assets.doomemacs.org/completion/vertico/search-replace.png
2021-04-10 14:44:27 +03:00
2021-06-09 18:14:36 +03:00
** In-buffer searching
2021-05-17 15:44:39 +03:00
This module provides some in buffer searching bindings:
2021-04-10 14:44:27 +03:00
2021-10-16 01:21:31 +02:00
- [[kbd: ][SPC s s ]] (~isearch~ )
- [[kbd: ][SPC s S ]] (~+vertico/search-symbol-at-point~ via ~consult-line~ )
- [[kbd: ][SPC s b ]] (~consult-line~ )
2021-04-10 14:44:27 +03:00
2021-07-09 20:16:11 +03:00
https://assets.doomemacs.org/completion/vertico/buffer-search.png
2021-04-10 14:44:27 +03:00
2021-10-16 01:21:31 +02:00
An ~occur-edit~ buffer can be opened from ~consult-line~ with [[kbd: ][C-c C-e ]].
2021-04-10 14:44:27 +03:00
2021-07-09 19:59:44 +03:00
** Vertico integration for various completing commands
2021-04-10 14:44:27 +03:00
*** General
2021-10-16 01:21:31 +02:00
| Keybind | Description |
|------------+-----------------------------|
| [[kbd:][M-x]], [[kbd:][SPC :]] | Enhanced M-x |
| [[kbd:][SPC ']] | Resume last Vertico session |
2021-04-10 14:44:27 +03:00
*** Jump to files, buffers or projects
2021-10-16 01:21:31 +02:00
| Keybind | Description |
|------------------+---------------------------------------|
| [[kbd:][SPC RET]] | Find bookmark |
| [[kbd:][SPC f f]], [[kbd:][SPC .]] | Browse from current directory |
| [[kbd:][SPC p f]], [[kbd:][SPC SPC]] | Find file in project |
| [[kbd:][SPC f r]] | Find recently opened file |
| [[kbd:][SPC p p]] | Open another project |
| [[kbd:][SPC b b]], [[kbd:][SPC ,]] | Switch to buffer in current workspace |
| [[kbd:][SPC b B]], [[kbd:][SPC <]] | Switch to buffer |
[[kbd: ][SPC b b ]] and [[kbd: ][SPC , ]] support changing the workspace you're selecting a buffer from
2021-05-21 16:38:54 +03:00
via [[https://github.com/minad/consult#narrowing-and-grouping ][Consult narrowing ]], e.g. if you're on the first workspace, you can switch to
2021-10-16 01:21:31 +02:00
selecting a buffer from the third workspace by typing [[kbd: ][3 SPC ]] into the prompt, or
the last workspace by typing [[kbd: ][0 SPC ]].
2021-05-21 16:38:54 +03:00
2021-10-16 01:21:31 +02:00
[[kbd: ][SPC f f ]] and [[kbd: ][SPC . ]] support exporting to a [[kbd: ][wdired ]] buffer using [[kbd: ][C-c C-e ]].
2021-05-21 13:19:52 +03:00
2021-04-10 14:44:27 +03:00
*** Search
2021-10-16 01:21:31 +02:00
| Keybind | Description |
|---------+-------------------------------------------|
| [[kbd:][SPC p t]] | List all TODO/FIXMEs in project |
| [[kbd:][SPC s b]] | Search the current buffer |
| [[kbd:][SPC s d]] | Search this directory |
| [[kbd:][SPC s D]] | Search another directory |
| [[kbd:][SPC s i]] | Search for symbol in current buffer |
| [[kbd:][SPC s p]] | Search project |
| [[kbd:][SPC s P]] | Search another project |
| [[kbd:][SPC s s]] | Search the current buffer (incrementally) |
2021-05-08 15:54:27 +03:00
2021-08-22 16:46:14 +03:00
*** 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 =~/= .
2021-08-10 18:29:49 +03:00
** Consult
*** Multiple candidate search
2021-07-31 10:43:00 +03:00
This module modifies the default keybindings used in
~consult-completing-read-multiple~ :
| Keybind | Description |
|---------+-------------------------------------------------------------|
2021-10-16 01:21:31 +02:00
| [[kbd:][TAB]] | Select or deselect current candidate |
| [[kbd:][RET]] | Enters selected candidates (also toggles current candidate) |
2021-07-31 10:43:00 +03:00
2021-08-10 18:29:49 +03:00
*** Async search commands
2021-10-16 01:21:31 +02:00
:PROPERTIES:
:ID: 4ab16bf0-f9e8-4798-8632-ee7b13d2291e
:END:
2021-08-07 03:20:50 +03:00
Consult async commands (e.g. ~consult-ripgrep~ ) will have a preceding separator
2021-10-16 01:21:31 +02:00
character (usually ~#~ ) before the search input. This is known as the =perl=
2021-08-07 03:20:50 +03:00
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
2022-09-26 02:19:42 +08:00
filtered with Emacs instead (and can be filtered using [[doom-package:orderless ]], for example).
2021-10-16 01:21:31 +02:00
The specific seperator character can be changed by editing it, and might be
different if the initial input already contains =#= .
2021-08-07 03:20:50 +03:00
2021-08-10 18:29:49 +03:00
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 =#= .
2021-08-07 03:20:50 +03:00
For more information [[https://github.com/minad/consult#asynchronous-search ][see here ]].
2021-07-11 20:01:27 +03:00
** Marginalia
| Keybind | Description |
|---------+---------------------------------|
2021-10-16 01:21:31 +02:00
| [[kbd:][M-A]] | Cycle between annotation levels |
2021-07-11 20:01:27 +03:00
2021-10-16 01:21:31 +02:00
Marginalia annotations for symbols (e.g. [[kbd: ][SPC h f ]] and [[kbd: ][SPC h v ]]) come with extra
information the nature of the symbol. For the meaning of the annotations see
~marginalia--symbol-class~ .
2021-08-15 23:57:22 +03:00
2021-05-08 15:54:27 +03:00
** Orderless filtering
When using orderless to filter through candidates, the default behaviour is for
2021-05-20 22:09:41 +03:00
each space separated input to match the candidate as a regular expression or
2021-05-17 13:42:45 +03:00
literally.
2021-06-09 18:14:36 +03:00
Note that due to this style of matching, pressing tab does not expand the input
to the longest matching prefix (like shell completion), but rather uses the
first matched candidate as input. Filtering further is instead achieved by
pressing space and entering another input. In essence, when trying to match
=foobar.org= , instead of option 1., use option 2.:
2021-10-16 01:21:31 +02:00
1. (BAD) Enter ~foo TAB~ , completes to =foobar.= , enter ~org RET~
2. (GOOD) Enter ~foo SPC org RET~
2021-06-09 18:14:36 +03:00
2021-10-16 01:21:31 +02:00
Doom has some builtin [[https://github.com/oantolin/orderless#style-dispatchers ][style dispatchers ]] for more fine-grained filtering, which
2021-05-20 22:09:41 +03:00
you can use to further specify each space separated input in the following ways:
2021-10-16 01:21:31 +02:00
| Input | Description |
|--------------+------------------------------------------|
| ~!foo~ | match without literal input =foo= |
| ~%foo~ or ~foo%~ | perform ~char-fold-to-regexp~ on input =foo= |
| ~`foo~ or ~foo`~ | match input =foo= as an initialism |
| ~=foo~ or ~foo=~ | match only with literal input =foo= |
| ~~foo~ or ~foo~~ | match input =foo= with fuzzy/flex matching |
* TODO Configuration
#+begin_quote
🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module: ][Complete it? ]]
#+end_quote
If you want to further configure this module, here are some good places to
start:
2021-08-07 03:20:50 +03:00
** Vertico
Vertico provides several [[https://github.com/minad/vertico#extensions ][extentions ]] that can be used to extend it's interface
2021-10-16 01:21:31 +02:00
2021-08-07 03:20:50 +03:00
** 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
2022-10-17 08:07:04 +03:00
(setq consult--customize-alist nil)
2021-10-16 01:21:31 +02:00
(consult-customize ...)
2021-08-07 03:20:50 +03:00
#+end_src
2021-10-16 01:21:31 +02:00
If you are changing the preview key (set to [[kbd: ][C-SPC ]]), remember to change the
2021-09-15 01:14:49 +03:00
binding on ~vertico-map~ as well, as the binding there gets previews to work to
an extent on non-consult commands as well.
2021-10-16 01:21:31 +02:00
2021-08-07 03:20:50 +03:00
** Marginalia
You can add more Marginalia annotation levels and change the existing ones by
2021-10-16 01:21:31 +02:00
editing ~marginalia-annotator-registry~
2021-08-07 03:20:50 +03:00
** Embark
You can change the available commands in Embark for category ~$cat~ by editing
2021-10-16 01:21:31 +02:00
~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.
* Troubleshooting
/There are no known problems with this module./ [[doom-report: ][Report one? ]]
* Frequently asked questions
[[doom-suggest-faq: ][Ask a question? ]]
** Helm vs Ivy vs Ido vs Vertico
See [[id:4f36ae11-1da8-4624-9c30-46b764e849fc ][this answer ]].
* TODO Appendix
#+begin_quote
🔨 This module has no appendix yet. [[doom-contrib-module: ][Write one? ]]
#+end_quote