Git Product home page Git Product logo

vertico's Introduction

vertico.el - VERTical Interactive COmpletion

GNU Emacs GNU ELPA GNU-devel ELPA MELPA MELPA Stable

Vertico provides a performant and minimalistic vertical completion UI based on the default completion system. The focus of Vertico is to provide a UI which behaves correctly under all circumstances. By reusing the built-in facilities system, Vertico achieves full compatibility with built-in Emacs completion commands and completion tables. Vertico only provides the completion UI but aims to be highly flexible, extendable and modular. Additional enhancements are available as extensions or complementary packages. The code base is small and maintainable. The main vertico.el package is only about 600 lines of code without white space and comments.

Features

  • Vertical display with arrow key navigation. Many additional display modes are provided as extensions.
  • Prompt shows the current candidate index and the total number of candidates.
  • The current candidate is inserted with TAB and selected with RET.
  • Non-existing candidates can be submitted with M-RET or by moving the point to the prompt.
  • Efficient sorting by history position, length and alphabetically.
  • Long candidates with newlines are formatted to take up less space.
  • Lazy completion candidate highlighting for performance.
  • Annotations are displayed next to the candidates (annotation- and affixation-function).
  • Support for candidate grouping and group cycling commands (group-function).

https://github.com/minad/vertico/blob/screenshots/vertico-mx.png?raw=true

Installation

Vertico is available from GNU ELPA. You can install it directly via M-x package-install RET vertico RET. After installation, activate the global minor mode with M-x vertico-mode RET.

Key bindings

Vertico defines its own local keymap in the minibuffer which is derived from minibuffer-local-map. The keymap keeps most of the fundamental-mode keybindings intact and remaps and binds only a handful of commands.

Binding/RemappingVertico command
beginning-of-buffer, minibuffer-beginning-of-buffervertico-first
end-of-buffervertico-last
scroll-down-commandvertico-scroll-down
scroll-up-commandvertico-scroll-up
next-line, next-line-or-history-elementvertico-next
previous-line, previous-line-or-history-elementvertico-previous
forward-paragraphvertico-next-group
backward-paragraphvertico-previous-group
exit-minibuffervertico-exit
kill-ring-savevertico-save
M-RETvertico-exit-input
TABvertico-insert

Note in particular the binding of TAB to vertico-insert, which inserts the currently selected candidate, and the binding of RET and M-RET to vertico-exit and vertico-exit-input respectively.

vertico-exit exits with the currently selected candidate, while vertico-exit-input exits with the minibuffer input instead. Exiting with the current input is needed when you want to create a new buffer or a new file with find-file or switch-to-buffer. As an alternative to pressing M-RET, move the selection up to the input prompt by pressing the up arrow key and then press RET.

Configuration

In order to configure Vertico and other packages in your init.el, you may want to take advantage of use-package. Here is an example configuration:

;; Enable vertico
(use-package vertico
  :init
  (vertico-mode)

  ;; Different scroll margin
  ;; (setq vertico-scroll-margin 0)

  ;; Show more candidates
  ;; (setq vertico-count 20)

  ;; Grow and shrink the Vertico minibuffer
  ;; (setq vertico-resize t)

  ;; Optionally enable cycling for `vertico-next' and `vertico-previous'.
  ;; (setq vertico-cycle t)
  )

;; Persist history over Emacs restarts. Vertico sorts by history position.
(use-package savehist
  :init
  (savehist-mode))

;; A few more useful configurations...
(use-package emacs
  :init
  ;; Add prompt indicator to `completing-read-multiple'.
  ;; We display [CRM<separator>], e.g., [CRM,] if the separator is a comma.
  (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)

  ;; Do not allow the cursor in the minibuffer prompt
  (setq minibuffer-prompt-properties
        '(read-only t cursor-intangible t face minibuffer-prompt))
  (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)

  ;; Support opening new minibuffers from inside existing minibuffers.
  (setq enable-recursive-minibuffers t)

  ;; Emacs 28 and newer: Hide commands in M-x which do not work in the current
  ;; mode.  Vertico commands are hidden in normal buffers. This setting is
  ;; useful beyond Vertico.
  (setq read-extended-command-predicate #'command-completion-default-include-p))

I recommend to give Orderless completion a try, which is different from the prefix TAB completion used by the basic default completion system or in shells.

;; Optionally use the `orderless' completion style.
(use-package orderless
  :init
  ;; Configure a custom style dispatcher (see the Consult wiki)
  ;; (setq orderless-style-dispatchers '(+orderless-consult-dispatch orderless-affix-dispatch)
  ;;       orderless-component-separator #'orderless-escapable-split-on-space)
  (setq completion-styles '(orderless basic)
        completion-category-defaults nil
        completion-category-overrides '((file (styles partial-completion)))))

The basic completion style is specified as fallback in addition to orderless in order to ensure that completion commands which rely on dynamic completion tables, e.g., completion-table-dynamic or completion-table-in-turn, work correctly. See the Consult wiki for my advanced Orderless configuration with style dispatchers. Additionally enable partial-completion for file path expansion. partial-completion is important for file wildcard support in find-file. In order to open multiple files with a wildcard at once, you have to submit the prompt with M-RET. Alternative first move to the prompt and then press RET.

See also the Vertico Wiki for additional configuration tips. For more general documentation read the chapter about completion in the Emacs manual. If you want to create your own completion commands, you can find documentation about completion in the Elisp manual.

Completion styles and TAB completion

The bindings of the minibuffer-local-completion-map are not available in Vertico by default. This means that TAB works differently from what you may expect from shells like Bash or the default Emacs completion system. In Vertico TAB inserts the currently selected candidate.

If you prefer to have the default completion commands available you can add new bindings or even replace the Vertico bindings. For example you can use M-TAB to expand the prefix of candidates (TAB complete) or cycle between candidates if completion-cycle-threshold is non-nil.

;; Option 1: Additional bindings
(keymap-set vertico-map "?" #'minibuffer-completion-help)
(keymap-set vertico-map "M-RET" #'minibuffer-force-complete-and-exit)
(keymap-set vertico-map "M-TAB" #'minibuffer-complete)

;; Option 2: Replace `vertico-insert' to enable TAB prefix expansion.
;; (keymap-set vertico-map "TAB" #'minibuffer-complete)

The orderless completion style does not support expansion of a common candidate prefix, as supported by shells or the basic default completion system. The reason is that the Orderless input string is usually not a prefix. In order to support completing prefixes, combine orderless with substring in your completion-styles configuration.

(setq completion-styles '(substring orderless basic))

Alternatively you can use the built-in completion-styles, e.g., partial-completion, flex or initials. The partial-completion style is important if you want to open multiple files at once with find-file using wildcards. In order to open multiple files with a wildcard at once, you have to submit the prompt with M-RET. Alternative first move to the prompt and then press RET.

(setq completion-styles '(basic substring partial-completion flex))

Because Vertico is fully compatible with Emacs default completion system, further customization of completion behavior can be achieved by setting the designated Emacs variables. For example, one may wish to disable case-sensitivity for file and buffer matching when built-in completion styles are used instead of orderless:

(setq read-file-name-completion-ignore-case t
      read-buffer-completion-ignore-case t
      completion-ignore-case t)

Completion-at-point and completion-in-region

The tab completion command completion-at-point command is usually bound to M-TAB or TAB. Tab completion is also used in the minibuffer by M-: (eval-expression). In case you want to use Vertico to show the completion candidates of completion-at-point and completion-in-region, you can use the function consult-completion-in-region provided by the Consult package.

;; Use `consult-completion-in-region' if Vertico is enabled.
;; Otherwise use the default `completion--in-region' function.
(setq completion-in-region-function
      (lambda (&rest args)
        (apply (if vertico-mode
                   #'consult-completion-in-region
                 #'completion--in-region)
               args)))

You may also want to look into my Corfu package, which provides a minimal completion system for completion-in-region in a child frame popup. Corfu is a narrowly focused package and developed in the same spirit as Vertico. You can even use Corfu in the minibuffer.

Extensions

We maintain small extension packages to Vertico in this repository in the subdirectory extensions/. The extensions are installed together with Vertico if you pull the package from ELPA. The extensions are inactive by default and can be enabled manually if desired. Furthermore it is possible to install all of the files separately, both vertico.el and the vertico-*.el extensions. Currently the following extensions come with the Vertico ELPA package:

  • vertico-buffer: vertico-buffer-mode to display Vertico like a regular buffer.
  • vertico-directory: Commands for Ido-like directory navigation.
  • vertico-flat: vertico-flat-mode to enable a flat, horizontal display.
  • vertico-grid: vertico-grid-mode to enable a grid display.
  • vertico-indexed: vertico-indexed-mode to select indexed candidates with prefix arguments.
  • vertico-mouse: vertico-mouse-mode to support for scrolling and candidate selection.
  • vertico-multiform: Configure Vertico modes per command or completion category.
  • vertico-quick: Commands to select using Avy-style quick keys.
  • vertico-repeat: The command vertico-repeat repeats the last completion session.
  • vertico-reverse: vertico-reverse-mode to reverse the display.
  • vertico-suspend: The command vertico-suspend suspends and restores the current session.
  • vertico-unobtrusive: vertico-unobtrusive-mode displays only the topmost candidate.

See the commentary of those files for configuration details. With these extensions it is possible to adapt Vertico such that it matches your preference or behaves similar to other familiar UIs. For example, the combination vertico-flat plus vertico-directory resembles Ido in look and feel. For an interface similar to Helm, the extension vertico-buffer allows you to configure freely where the completion buffer opens, instead of growing the minibuffer. Furthermore vertico-buffer will adjust the number of displayed candidates according to the buffer height.

Configuration example for vertico-directory:

;; Configure directory extension.
(use-package vertico-directory
  :after vertico
  :ensure nil
  ;; More convenient directory navigation commands
  :bind (:map vertico-map
              ("RET" . vertico-directory-enter)
              ("DEL" . vertico-directory-delete-char)
              ("M-DEL" . vertico-directory-delete-word))
  ;; Tidy shadowed file names
  :hook (rfn-eshadow-update-overlay . vertico-directory-tidy))

Configure Vertico per command or completion category

https://github.com/minad/vertico/blob/screenshots/vertico-ripgrep.png?raw=true

Vertico offers the vertico-multiform-mode which allows you to configure Vertico per command or per completion category. The vertico-buffer-mode enables a Helm-like buffer display, which takes more space but also displays more candidates. This verbose display mode is useful for commands like consult-imenu or consult-outline since the buffer display allows you to get a better overview over the entire current buffer. But for other commands you want to keep using the default Vertico display. vertico-multiform-mode solves this configuration problem.

;; Enable vertico-multiform
(vertico-multiform-mode)

;; Configure the display per command.
;; Use a buffer with indices for imenu
;; and a flat (Ido-like) menu for M-x.
(setq vertico-multiform-commands
      '((consult-imenu buffer indexed)
        (execute-extended-command unobtrusive)))

;; Configure the display per completion category.
;; Use the grid display for files and a buffer
;; for the consult-grep commands.
(setq vertico-multiform-categories
      '((file grid)
        (consult-grep buffer)))

Temporary toggling between the different display modes is possible. The following commands are bound by default in the vertico-multiform-map. You can of course change these bindings if you like.

  • M-B -> vertico-multiform-buffer
  • M-F -> vertico-multiform-flat
  • M-G -> vertico-multiform-grid
  • M-R -> vertico-multiform-reverse
  • M-U -> vertico-multiform-unobtrusive
  • M-V -> vertico-multiform-vertical

For special configuration you can use your own functions or even lambdas to configure the completion behavior per command or per completion category. Functions must have the calling convention of a mode, i.e., take a single argument, which is either 1 to turn on the mode and -1 to turn off the mode.

;; Configure `consult-outline' as a scaled down TOC in a separate buffer
(setq vertico-multiform-commands
      `((consult-outline buffer ,(lambda (_) (text-scale-set -1)))))

Furthermore you can tune buffer-local settings per command or category.

;; Change the default sorting function.
;; See `vertico-sort-function' and `vertico-sort-override-function'.
(setq vertico-multiform-commands
      '((describe-symbol (vertico-sort-function . vertico-sort-alpha))))

(setq vertico-multiform-categories
      '((symbol (vertico-sort-function . vertico-sort-alpha))
        (file (vertico-sort-function . sort-directories-first))))

;; Sort directories before files
(defun sort-directories-first (files)
  (setq files (vertico-sort-history-length-alpha files))
  (nconc (seq-filter (lambda (x) (string-suffix-p "/" x)) files)
         (seq-remove (lambda (x) (string-suffix-p "/" x)) files)))

Combining these features allows us to fine-tune the completion display even more by adjusting the vertico-buffer-display-action. We can for example reuse the current window for commands of the consult-grep category (consult-grep, consult-git-grep and consult-ripgrep). Note that this configuration is incompatible with Consult preview, since the previewed buffer is usually shown in exactly this window. Nevertheless this snippet demonstrates the flexibility of the configuration system.

;; Configure the buffer display and the buffer display action
(setq vertico-multiform-categories
      '((consult-grep
         buffer
         (vertico-buffer-display-action . (display-buffer-same-window)))))

;; Disable preview for consult-grep commands
(consult-customize consult-ripgrep consult-git-grep consult-grep :preview-key nil)

As another example, the following code uses vertico-flat and vertico-cycle to emulate (ido-mode 'buffer), i.e., Ido when it is enabled only for completion of buffer names. vertico-cycle set to t is necessary here to prevent completion candidates from disappearing when they scroll off-screen to the left.

(setq vertico-multiform-categories
      '((buffer flat (vertico-cycle . t))))

Complementary packages

Vertico integrates well with complementary packages, which enrich the completion UI. These packages are fully supported:

  • Marginalia: Rich annotations in the minibuffer
  • Consult: Useful search and navigation commands
  • Embark: Minibuffer actions and context menu
  • Orderless: Advanced completion style

In order to get accustomed with the package ecosystem, I recommend the following quick start approach:

  1. Start with plain Emacs (emacs -Q).
  2. Install and enable Vertico to get incremental minibuffer completion.
  3. Install Orderless and/or configure the built-in completion styles for more flexible minibuffer filtering.
  4. Install Marginalia if you like rich minibuffer annotations.
  5. Install Embark and add two keybindings for embark-dwim and embark-act. I am using the mnemonic keybindings M-. and C-. since these commands allow you to act on the object at point or in the minibuffer.
  6. Install Consult if you want additional featureful completion commands, e.g., the buffer switcher consult-buffer with preview or the line-based search consult-line.
  7. Install Embark-Consult and Wgrep for export from consult-line to occur-mode buffers and from consult-grep to editable grep-mode buffers.
  8. Fine tune Vertico with extensions.

The ecosystem is modular. You don’t have to use all of these components. Use only the ones you like and the ones which fit well into your setup. The steps 1. to 4. introduce no new commands over plain Emacs. Step 5. introduces the new commands embark-act and embark-dwim. In step 6. you get the Consult commands, some offer new functionality not present in Emacs already (e.g., consult-line) and some are substitutes (e.g., consult-buffer for switch-to-buffer).

Child frames and Popups

An often requested feature is the ability to display the completions in a child frame popup. Personally I am critical of using child frames for minibuffer completion. From my experience it introduces more problems than it solves. Most importantly child frames hide the content of the underlying buffer. Furthermore child frames do not play well together with changing windows and entering recursive minibuffer sessions. On top, child frames can feel slow and sometimes flicker. A better alternative is the vertico-buffer display which can even be configured individually per command using vertico-multiform. On the plus side of child frames, the completion display appears at the center of the screen, where your eyes are focused. Please give the following packages a try and judge for yourself.

  • mini-frame: Display the entire minibuffer in a child frame.
  • mini-popup: Slightly simpler alternative to mini-frame.
  • vertico-posframe: Display only the Vertico minibuffer in a child frame using the posframe library.

Alternatives

There are many alternative completion UIs, each UI with its own advantages and disadvantages.

Vertico aims to be 100% compliant with all Emacs commands and achieves that with a minimal code base, relying purely on completing-read while avoiding to invent its own APIs. Inventing a custom API as Helm or Ivy is explicitly avoided in order to increase flexibility and package reuse. Due to its small code base and reuse of the Emacs built-in facilities, bugs and compatibility issues are less likely to occur in comparison to completion UIs or monolithic completion systems.

Since Vertico only provides the UI, you may want to combine it with some of the complementary packages, to give a full-featured completion experience similar to Helm or Ivy. The idea is to have smaller independent components, which one can add and understand step by step. Each component focuses on its niche and tries to be as non-intrusive as possible. Vertico targets users interested in crafting their Emacs precisely to their liking - completion plays an integral part in how the users interacts with Emacs.

There are other interactive completion UIs, which follow a similar philosophy:

  • Mct: Minibuffer and Completions in Tandem. Mct reuses the default *Completions* buffer and enhances it with automatic updates and additional keybindings, to select a candidate and move between minibuffer and completions buffer. Since Mct uses a fully functional buffer you can use familiar buffer commands inside the completions buffer. The main distinction to Vertico’s approach is that *Completions* buffer displays all matching candidates. This has the advantage that you can interact freely with the candidates and jump around with Isearch or Avy. On the other hand it necessarily causes a slowdown.
  • Selectrum: Selectrum is the predecessor of Vertico has been deprecated in favor of Vertico. Read the migration guide when migrating from Selectrum. Vertico was designed specifically to address the technical shortcomings of Selectrum. Selectrum is not fully compatible with every Emacs completion command and dynamic completion tables, since it uses its own filtering infrastructure, which deviates from the standard Emacs completion facilities.
  • Icomplete: Emacs 28 comes with a builtin icomplete-vertical-mode, which is a more bare-bone than Vertico. Vertico offers additional flexibility thanks to its extensions.

Resources

If you want to learn more about Vertico and minibuffer completion, check out the following resources:

Contributions

Since this package is part of GNU ELPA contributions require a copyright assignment to the FSF.

Debugging Vertico

When you observe an error in the vertico--exhibit post command hook, you should install an advice to enforce debugging. This allows you to obtain a stack trace in order to narrow down the location of the error. The reason is that post command hooks are automatically disabled (and not debugged) by Emacs. Otherwise Emacs would become unusable, given that the hooks are executed after every command.

(setq debug-on-error t)

(defun force-debug (func &rest args)
  (condition-case e
      (apply func args)
    ((debug error) (signal (car e) (cdr e)))))

(advice-add #'vertico--exhibit :around #'force-debug)

Problematic completion commands

Vertico is robust in most scenarios. However some completion commands make certain assumptions about the completion styles and the completion UI. Some of these assumptions may not hold in Vertico or other UIs and require minor workarounds.

org-refile

org-refile uses org-olpath-completing-read to complete the outline path in steps, when org-refile-use-outline-path is non-nil.

Unfortunately the implementation of this Org completion table assumes that the basic completion style is used. The table is incompatible with completion styles like substring, flex or orderless. In order to fix the issue at the root, the completion table should make use of completion boundaries similar to the built-in file completion table. In your user configuration you can prioritize basic before orderless.

;; Alternative 1: Use the basic completion style
(setq org-refile-use-outline-path 'file
      org-outline-path-complete-in-steps t)

(advice-add #'org-olpath-completing-read :around #'vertico-enforce-basic-completion)

(defun vertico-enforce-basic-completion (&rest args)
  (minibuffer-with-setup-hook
      (:append
       (lambda ()
         (let ((map (make-sparse-keymap)))
           (define-key map [tab] #'minibuffer-complete)
           (use-local-map (make-composed-keymap (list map) (current-local-map))))
         (setq-local completion-styles (cons 'basic completion-styles)
                     vertico-preselect 'prompt)))
    (apply args)))

Alternatively you may want to disable the outline path completion in steps. The completion on the full path can be quicker since the input string matches directly against substrings of the full path, which is useful with Orderless. However the list of possible completions becomes much more cluttered.

;; Alternative 2: Complete full paths
(setq org-refile-use-outline-path 'file
      org-outline-path-complete-in-steps nil)

org-agenda-filter and org-tags-view

Similar to org-refile, the commands org-agenda-filter and org-tags-view do not make use of completion boundaries. The internal completion tables are org-agenda-filter-completion-function and org-tags-completion-function. Unfortunately TAB completion (minibuffer-complete) does not work for this reason with arbitrary completion styles like substring, flex or orderless. This affects Vertico and also the Emacs default completion system. For example if you enter +tag<0 TAB the input is replaced with 0:10 which is not correct. With preserved completion boundaries, the expected result would be +tag<0:10. Completion boundaries are used for example by file completion, where each part of the path can be completed separately. Ideally this issue would be fixed in Org.

(advice-add #'org-make-tags-matcher :around #'vertico-enforce-basic-completion)
(advice-add #'org-agenda-filter :around #'vertico-enforce-basic-completion)

tmm-menubar

The text menu bar works well with Vertico but always shows a *Completions* buffer, which is unwanted if you use the Vertico UI. This completion buffer can be disabled with an advice. If you disabled the standard GUI menu bar and prefer the Vertico interface you may also overwrite the default F10 keybinding.

(keymap-global-set "<f10>" #'tmm-menubar)
(advice-add #'tmm-add-prompt :after #'minibuffer-hide-completions)

ffap-menu

The command ffap-menu shows the *Completions* buffer by default like tmm-menubar, which is unnecessary with Vertico. This completion buffer can be disabled as follows.

(advice-add #'ffap-menu-ask :around
            (lambda (&rest args)
              (cl-letf (((symbol-function #'minibuffer-completion-help)
                         #'ignore))
                (apply args))))

completion-table-dynamic

Dynamic completion tables (completion-table-dynamic, completion-table-in-turn, …) should work well with Vertico. The only requirement is that the basic completion style is enabled. The basic style performs prefix filtering by passing the input to the completion table (or the dynamic completion table function). The basic completion style must not necessarily be configured with highest priority, it can also come after other completion styles like orderless, substring or flex, as is also recommended by the Orderless documentation because of completion-table-dynamic.

(setq completion-styles '(basic))
;; (setq completion-styles '(orderless basic))
(completing-read "Dynamic: "
                 (completion-table-dynamic
                  (lambda (str)
                    (list (concat str "1")
                          (concat str "2")
                          (concat str "3")))))

Submitting the empty string

The commands multi-occur, auto-insert, bbdb-create read multiple arguments from the minibuffer with completing-read, one at a time, until you submit an empty string. You should type M-RET (vertico-exit-input) to finish the loop. Directly pressing RET (vertico-exit) does not work since the first candidate is preselected.

The underlying issue is that completing-read always allows you to exit with the empty string, which is called the null completion, even if the REQUIRE-MATCH argument is non-nil. Try the following two calls to completing-read with C-x C-e:

(completing-read "Select: " '("first" "second" "third") nil 'require-match)
(completing-read "Select: " '("first" "second" "third") nil 'require-match nil nil "")

In both cases the empty string can be submitted. In the first case no explicit default value is specified and Vertico preselects the first candidate. In order to exit with the empty string, press M-RET. In the second case the explicit default value “” is specified and Vertico preselects the prompt, such that exiting with the empty string is possible by pressing RET only.

Tramp hostname and username completion

NOTE: On upcoming Emacs 29.2 and Tramp 2.6.1.5 the workarounds described in this section are not necessary anymore, since the relevant completion tables have been improved.

In combination with Orderless or other non-prefix completion styles like substring or flex, host names and user names are not made available for completion after entering /ssh:. In order to avoid this problem, the basic completion style should be specified for the file completion category, such that basic is tried before orderless. This can be achieved by putting basic first in the completion style overrides for the file completion category.

(setq completion-styles '(orderless basic)
      completion-category-defaults nil
      completion-category-overrides '((file (styles basic partial-completion))))

If you are familiar with the completion-style machinery, you may also define a custom completion style which activates only for remote files. The custom completion style ensures that you can always match substrings within non-remote file names, since orderless will stay the preferred style for non-remote files.

(defun basic-remote-try-completion (string table pred point)
  (and (vertico--remote-p string)
       (completion-basic-try-completion string table pred point)))
(defun basic-remote-all-completions (string table pred point)
  (and (vertico--remote-p string)
       (completion-basic-all-completions string table pred point)))
(add-to-list
 'completion-styles-alist
 '(basic-remote basic-remote-try-completion basic-remote-all-completions nil))
(setq completion-styles '(orderless basic)
      completion-category-defaults nil
      completion-category-overrides '((file (styles basic-remote partial-completion))))

vertico's People

Contributors

aaronjensen avatar abcdw avatar arialdomartini avatar astoff avatar daanturo avatar divinedominion avatar dr-scsi avatar gcv avatar jdtsmith avatar jtamagnan avatar kyanagi avatar lebensterben avatar manuel-uberti avatar mihakam avatar minad avatar okamsn avatar phikal avatar rossabaker avatar skrytebane avatar ssnnoo avatar tarsius avatar tsuu32 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vertico's Issues

How to determine the number of completion candidates?

In am having a rather particular problem in my attempts to potentially migrate to vertico:

In my setup I am using the mini-frame package to show my minibuffer in a child-frame. It does have an option to change the child-frame's size depending on the size of the input. However the way it is implemented the frame will flicker when its size changes between calls: muffinmad/emacs-mini-frame#38

As a workaround I use a function that dynamically determines the mini-frame's frame parameters to include a height value. That way the frame has the right size before it appears and there is no flicker.

To make that happen I need to know how many completion candidates there are, so I can adjust the height when there are fewer than X candidates or reduce it to 1 line when I'm seeing a read-string or y-or-n-p call.

With my current selectrum setup I advise selectrum--read which allows me to grab the list off candidates and use it for my height check. However with vertico I haven't been able to find such an entry point. The order of execution is such that when mini-frame's hook is called both vertico--candidates and minibuffer-completion-table are nil.

Is my convoluted setup workable with vertico, or should I stick with selectrum?

If you want to see for yourself you'll need about the following setup:

(setf
 mini-frame-resize          nil
 mini-frame-show-parameters #'std::mini-frame-show-parameters)

(defun std::mini-frame-show-parameters ()
  ;; determinig the height goes here
  `((background-color . "#2E2E32")
    (left . 0.5)
    (top . 40)
    (height . 10)
    (width . 0.9)))

(mini-frame-mode)

readme information about build-in completion styles - ignore case

I use vertico with emacs build-in completion styles:

(setq completion-styles '(basic substring partial-completion emacs22 flex))

and this works quite well (similar to ido etc) with

(setq read-file-name-completion-ignore-case t)
(setq read-buffer-completion-ignore-case t)

would it be worthwhile to mention these two variables in the readme when mentioning that it is also possible to not use orderless?

Copy to root of current Dired, not first candidate

Hello Daniel, I started experimenting with vertico to make some suggestions, as you requested. I found an issue where if you try to copy/rename from one Dired buffer to another, without providing any minibuffer input, it copies/renames to the first matching candidate.

Here is a scenario with (setq dired-dwim-target t):

Screenshot from 2021-04-07 09-09-58

If I hit RET it will copy the file to the doc/ subdirectory instead of .. Can you reproduce this?

Face attributes from the candidates are still present when they get expanded to the prompt

When I'm M-x find-file the face attributes from the candidates get applied when the candidate is entered to the prompt.

See the picture below for an example. In the picture in the left side the candidates with pac are highlighted. When I press tab on the first candidate, the directory gets expanded and the prompt is updated (picture in the right side). The highlighting is propagated to the prompt. Is this expected? If so, can we add an option to disable this behaviour and have the prompt just have its regular face?

vertico

Insert the thing at point in the minibuffer

Hi,

is there a way to insert the word or symbol at point in the buffer from which the completion started to the minibuffer as a way to narrow the candidates? Here are 2 use cases:

  1. Find a file whose name is under point
    • Imagine you are writing some code and the point is on a class name. In your project, classes are in files with the same name (e.g., the class Circle is in a Circle.js file in the project). You want to open a buffer containing the file defining the class whose name is under the point. With ivy+projectile I can type C-c p f to list all files in the project with minibuffer completion and then press M-n to insert the class name under the point in the minibuffer. This immediately narrow the project files to those with the expected filename.
  2. Find a definition in the current buffer when at call site
    • Imagine you are in vertico.el with point on format in (vertico--display-candidates (vertico--format-candidates metadata)). You want to see the definition of this function. With imenu+ivy, I can press M-i to open imenu and M-n to insert vertico--format-candidates in the minibuffer and immediately narrow imenu results to those matching the symbol at point.

ivy implements this in ivy-next-history-element which I'm using 100 times a day.

Bottom candidates are cut off

When the candidate's height is higher than the default's height, the bottom candidates are cut off. Notice that, when running consult-outline in an Org buffer with three headings, Vertico only shows two:

image

This is particularly annoying as one can't see what one selects. This doesn't seem related to other (closed) issues regarding minibuffer height. Thank you in advance.

  • Emacs 27.2
  • vertico 0.4
  • resize-mini-windows set to t
  • vertico-count left to 10

feature request: check default-directory for dynamic remote completion over tramp

would you mind add a check for remote default-directory in vertico--update-candidates:

;; If Tramp is used, do not compute the candidates in an interruptible fashion,
      ;; since this will break the Tramp password and user name prompts (See #23).
      (if (and (eq 'file (completion-metadata-get metadata 'category))
               (or (string-match-p "\\`/[^/|:]+:" (substitute-in-file-name content))
                   ;; check default-directory too
                   (file-remote-p default-directory)))
          (vertico--recompute-candidates pt content bounds metadata)
          ;; bug#38024: Icomplete uses `while-no-input-ignore-events' to repair updating issues
        (let ((while-no-input-ignore-events '(selection-request))
              (non-essential t))
          (while-no-input (vertico--recompute-candidates pt content bounds metadata))))

my dynamic completion function returns a list of entries for file-names but in a special format, e.g.

ubifs.c in u-boot/cmd at /localdisk1/repos
ubifs.c in u-boot/fs/ubifs at /localdisk1/repos
ubifs.h in linux/fs/ubifs at /localdisk2/repos
...

handling of missing value not in completions list

Say we evaluate a completing read with a default that is not in the candidates list:

(completing-read "Option (default c): " '("a" "b") nil nil nil nil "c")

My expectation here would be to see "c" as the first possible completion, so that pressing RET actually selects the intended default, or, barring that, to see the c next to the prompt (for the same effect).

If i've tested correctly, that's how selectrum works. In vertico, one sees a prompt saying "Option (default c): " but with "a" being the selected candidate upon pressing RET (which feels as saying "by default", but it's not, one needs a M-n to get it).

I see how a case can be made for either behaviour, so this might well be by design, but i'd find it more intuitive if the default (c) were added to the list of candidates shown, and made the first option.

(Emacs 28, btw).

Cannot use vertico-mode for M-x in emacs -q

Vertico works perfectly in my personal configuration, but if I try emacs -Q, then M-x package-initialize, M-x vertico-mode, and then M-x again, Vertico displays the number of candidates: 1/3860 M-x and an error message:

Error in post-command-hook (vertico--exhibit): (wrong-type-argument stringp nil)

The error occurs with M-x, but not with find-file, for example.

M-x error in gccemacs

I've tried vertico today with gccemacs, the completion UI works for find-file, but on M-x, I got '[Error in post-command-hook (vertico--exhibit): (wrong-type-argument stringp nil)]'

Make the UI less bumpy with group titles/multiline candidates

It would be better to somehow count the lines of titles/multiline candidates such that the UI does not resize if one scrolls through the candidates. For example if you have two group titles, you would only see 8 candidates. I have to figure out a good way to do this such that one can still scroll smoothly through the candidates. This would also fix the corresponding problem in Selectrum (radian-software/selectrum#491).

Completion items title are invisible, but embark still showing their data

Trying out Vertico for the first time, I've done everything as shown in the readme. But when I try to open any menu, such as M-x for Find-File, the list is populated but actual items are invisible. Note that the marginalia stuff still shows up, and likewise if I M-w I copy the actual name of the item (the same name that I am unable to see).

When I turn off vertico-mode and turn on, e.g. selectrum-mode (after loading its package), Selectrum results show up fine. Why are my vertico results hidden?

image

newest master doesn't like vertico when M-x is called

i am almost sure this is not vertico's fault, but something updated during the last two days in emacs master, but perhaps someone will know of a quick workaround. since my latest update, trying to M-x produces the mystifying error

       Error in post-command-hook (vertico--exhibit): (error "Invalid version syntax: ‘Org 9.0’ (must start with a number)")

and vertico fails to start for completion. other uses, like completing buffers, etc. work well.

as i said, this is a plea for help rather than a bug report, so please feel free to close :) thanks!

Bottom prompt input, Reverse candidates, Buffer display

Hi, I'm testing vertico nowadays and remembered a thread in Selectrum issues you participated in regarding bottom prompt input: radian-software/selectrum#525

(setq selectrum-display-action '(display-buffer-at-bottom)) was a partial solution since it offered the prompt at the bottom line but the display of the candidates wasn't up side down (the top matches are not right above the input).

Do you plan to implement this in vertico as an option or by default by any chance?

Wrap around at beginning/end of completions?

Hey @minad, Vertico has been working great for me with a more recent build of native-comp! Everything feels really snappy and looks great with Marginalia. One thing I got used to while using Ivy is how when you move the selection up or down at the beginning or end of the list, the selection will wrap around to the other side of the list.

It looks like it could be easy to add a setting for this and update the logic here to respect it. I would submit a PR but I don't think I can do a FSF copyright assignment at the moment :(

If it's something you're not interested in adding for Vertico to keep things simple, I will understand :)

Show matches on no input?

Does vertico have the equivalent of icomplete-show-matches-on-no-input? I find it is often helpful to see the, e.g. available commands in M-x before typing anything (especially if savehist or prescient, etc., is being used). Thanks!

EDIT: I'm now thinking this might have to do with interaction between mini-frame and vertico, as I can see candidates on no input when mini-frame is disabled. Maybe this is a bug? I don't have this problem with mini-frame using, e.g., selectrum.

Variable minibuffer--require-match doesn't exist in some versions of Emacs

I have two computers with different Emacs 28 snapshots, the newer one has the variable and the older doesn't. It looks like Emacs 27 does have the variable, so I think the variable was removed and then re-added. I'm not sure if anything needs to be done about this, since Emacs 28 isn't out yet and it seems to have regained the variable, but I thought I'd let you know.

suggestion: add equivalent of ivy-partial-or-done

Hi!

First of all thanks for the package, it's really neat.

Can I ask you how would you convert the following to vertico? I could give it a try but I suspect that's something you might even want to add to the package.

(defun selectrum-insert-or-submit-current-candidate ()
  "Insert current candidate depending, or forward to
`selectrum-select-current-candidate' if input text hasn't changed since
last completion
Similar to ivy's `ivy-partial-or-done'."
  (interactive)
  (progn
    (let ((prev-input (selectrum-get-current-input)))
      (when (> (length (selectrum-get-current-candidates)) 0)
        (selectrum-insert-current-candidate))
      (when (string= prev-input (selectrum-get-current-input))
        (selectrum-select-current-candidate)))))

[question] possible to have a fixed height of minibuffer and completion buffer?

hello,
i whant to have to following design using vertico with minibuffer and completions buffer.
minibuffer should be e.g. max 3 line high and the completions buffer e.g. max 10 lines high.
if there are more candidates, i want scroll inside the buffers.
is it possible with vertico?
i googled a while and set some related variables, but none works.
(setq resize-mini-windows nil) ;; or t (setq max-mini-window-height 3)
do you know a way?

Regards
Poul

Previous / Next group navigation for multi-sources

Regarding my comment on minad/consult#6 (comment)

(defun vertico-next-group ()
  (interactive)
  (let ((group (car (get-text-property 0 'consult-multi (vertico--candidate))))
        (loop t))
    (while (and group loop)
      (if (= vertico--index (1- vertico--total))
          (progn
            (vertico-first)
            (setq loop nil))
        (vertico-next)
        (unless (equalp group (car (get-text-property 0 'consult-multi (vertico--candidate))))
          (setq loop nil))))))


(defun vertico-previous-group ()
  (interactive)
  (let ((group (car (get-text-property 0 'consult-multi (vertico--candidate))))
        (loop t))
    (while (and group loop)
      (if (zerop vertico--index)
          (progn
            (vertico-last)
            (setq loop nil))
        (vertico-previous)
        (unless (equalp group (car (get-text-property 0 'consult-multi (vertico--candidate))))
          (setq loop nil))))))


(define-key vertico-map '[C-left]  'vertico-previous-group)
(define-key vertico-map '[C-right] 'vertico-next-group)

I know, the implementation is very ugly, but it works ;-).
I don't specially like the mention of consult-multi text property to get the group symbol here in the vertico package, I don't know if there is a standard way to get it.

What do you think?

Minor problems with SVG screenshot in README

Hello Daniel! I just discovered your new package. Congratulations!

I noticed some issues with the transparency of screenshot.svg while using dark GTK/system themes:

Screenshot from 2021-04-06 19-42-50

Screenshot from 2021-04-06 19-42-55

And here is EWW (which should not be a priority, but I just note it in case you are curious):

Screenshot from 2021-04-06 19-47-42

Screenshot from 2021-04-06 19-47-46

Especially with the dark theme in Emacs, you can notice fine boxes inside the image, which I hypothesise is due to the blending of a transparency layer with the underlying background.

Hiding uninteresting file types

I really like vertigo. Is it possible to hide certain file types? This is particularly useful when using latex, at least for me.

Issue with native-compilation

I don't really know why, but when vertico is loaded from a .eln file, it's showing this behaviour.

Image of explained behaviour

You can note that the prompt isn't there. But when I eval-buffer vertico.el it just works as expected. Any idea what is happening there?

EDIT by @minad: The screenshot above does not reflect the bug anymore since @bbuccianti changed the uploaded image. (@bbuccianti note that you can use the gh image upload instead)

Save history of commands and stuff selected?

Hi!

First, thanks for creating this wonderful package. I was a selectrum user but vertico is definitely a lot better for myself because I don't use at least 80% of what selectrum offers.

But, I'm kind of missing the history capabilities of selectrum-prescient. Do you think would be imprudent or difficult to add this?

I'm referring especially to this use case. Emacs shows you the last used commands in some commands like M-x, but this only lasts for the session, I'm thinking of persist those. Maybe Emacs have that too? I don't know!

Thanks again!

Feedback and questions

Hi,

first of all thanks for this package. I have been trying it out since yesterday and so far it's a nice experience indeed, since it perfectly fits my basic minibuffer completion needs.

A couple of questions:

  • Do you plan to bind C-p and C-n to move around the candidates? As of now I can only do it with <up> and <down> (it could very well be my configuration, though I don't have this problem with selectrum)
  • Do you plan to make the counter optional? I rarely need it. For instance, with selectrum I only use it with consult-imenu and consult-ripgrep

[TRAMP] Filename completion slow on remote paths, password prompt

When I enable Vertico together with the partial-completion style for files, I experience unresponsiveness when reading file names on a SSH host with Tramp. I get the impression that, after each character I type, Emacs waits for a response from the remote server.

vertico doesn't seem to like orderless-flex

Error in post-command-hook (vertico--exhibit): (void-function nil)

vertico doesn't display or work beyond there using orderless-flex as the method.

vertico works fine with orderless as the method.

to reproduce --

(use-package orderless
  :ensure t
  :custom (completion-styles '(orderless-flex)))

Inserting dash with SPC

Hello and thank you for creating vertico. Previously I'd tried a few other minibuffer completion modes but nothing ever felt right. You've put an incredible amount of care and attention into vertico so it just feels right. Your work is much appreciated.

Over the years, I've grown very accustomed to inserting "-" (dash) in the minbuffer with the spacebar. This is the default if you're just using regular Emacs completing-read with no minibuffer completion modes.

I'd like to submit a PR that adds an option to retain this behaviour if that's something you're interested in? If so, would you like this as just a defcustom? To achieve this I'd just make SPC call a command vertico-self-insert-space that either calls (insert ?-) or self-insert-command depending on the value of the option.

Should there be a wiki?

Someone just asked me how to get ido-like behavior for RET during file completion in Vertico. Apparently in ido RET enters a directory instead of submitting it (you probably remember this from your ido days). I told that person to try this:

(defun ret-enters-drectory (_)
  (and minibuffer-completing-file-name
       (>= vertico--index 0)
       (string-suffix-p "/" (vertico--candidate))
       (progn (vertico-insert) t)))

(advice-add 'vertico-exit :before-until #'ret-enters-drectory)

I thought maybe I'd put that on the Vertico wiki, only to discover there isn't one. Would be worth adding one? (Maybe not, this is a very focused package and I don't imagine tons of tweaks to it.)

Also, while I'm here: does that seem like a good way to achieve the behavior?

When a minibuffer entry expects empty input

There are a few circumstance where the minibuffer provides a list of completion candidates but also expects empty input to end input.

An example of this calling auto-insert in an Emacs Lisp buffer, which will ask for package keywords, and will only proceed to the next skeleton insertion when minibuffer receives empty input. In this circumstance there is no way to proceed through the auto-insert skeleton and the user needs to call C-g to abort the process.

I'm not sure if there is an easy solution to this..?

Move Embark/Consult integration

For consistency it makes sense to move the Consult/Embark integrations to Consult/Embark, since these packages already provide integration code themselves and they somehow sit downstream of the actual completion systems. @oantolin I want to check first with you if you like this, since I am unsure how you feel about supporting such fringe completion systems.

(Secret motivation: The 500 line limit is about to fall...)

Highlight group titles?

In consult-grep the file name is moved to the group title and not highlighted anymore. If an Orderless highlight matches the filename it will be neither visible in the group title nor the candidate, even if it appears again in the candidate. Orderless only highlights the first match.

Funny sorting

In my setup with vertico and marginalia see the following candidates for insert-char. As you can see, the emoji BELL candidate takes place of the BELL control character.

image

Vertico breaks TRAMP

When vertico-mode is enabled, TRAMP breaks.
More specifically, when typing C-x C-f /sudo::, the password of the computer is asked.
Once the first key is pressed, TRAMP complains [Tramp: Opening connection for root@hostname using sudo...failed].
When vertico is disabled, TRAMP works perfectly.

digit arguments for vertico-next and vertico-previous

Can vertico-next and vertico-previous be made to take digit arguments? (Similar to next-line and previous-line.)

I often find myself pressing something like C-4 C-n in the minibuffer. I looked at the code but the check for vertico-cycle makes it a little trickier to trivially modify.

I've been trying out Vertico in light of our conversation in a recent Embark issue thread after a year long stint with Embark live-collect buffers. Vertico feels blazing fast in comparison! But naturally, I find myself missing the full buffer editing features, like jumping to candidates with isearch/avy or digit arguments on movement commands.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.