dotemacs

My Emacs configuration
git clone git://git.entf.net/dotemacs
Log | Files | Refs | LICENSE

README.org (26698B)


      1 #+title: corfu.el - Completion Overlay Region FUnction
      2 #+author: Daniel Mendler
      3 #+language: en
      4 #+export_file_name: corfu.texi
      5 #+texinfo_dir_category: Emacs misc features
      6 #+texinfo_dir_title: Corfu: (corfu).
      7 #+texinfo_dir_desc: Completion Overlay Region FUnction
      8 
      9 #+html: <a href="https://www.gnu.org/software/emacs/"><img alt="GNU Emacs" src="https://github.com/minad/corfu/blob/screenshots/emacs.svg?raw=true"/></a>
     10 #+html: <a href="https://elpa.gnu.org/packages/corfu.html"><img alt="GNU ELPA" src="https://elpa.gnu.org/packages/corfu.svg"/></a>
     11 #+html: <a href="https://elpa.gnu.org/devel/corfu.html"><img alt="GNU-devel ELPA" src="https://elpa.gnu.org/devel/corfu.svg"/></a>
     12 
     13 Corfu enhances completion at point with a small completion popup. The current
     14 candidates are shown in a popup below or above the point. Corfu is the
     15 minimalistic ~completion-in-region~ counterpart of the [[https://github.com/minad/vertico][Vertico]] minibuffer UI.
     16 
     17 Corfu is a small package, which relies on the Emacs completion facilities and
     18 concentrates on providing a polished completion UI. Completions are either
     19 provided by commands like ~dabbrev-completion~ or by pluggable backends
     20 (~completion-at-point-functions~, Capfs). Most programming language major modes
     21 implement a Capf. Furthermore the language server packages, Eglot and Lsp-mode,
     22 use Capfs which talk to the LSP server to retrieve the completions. Corfu does
     23 not include its own completion backends. The Emacs built-in Capfs and the Capfs
     24 provided by other programming language packages are usually sufficient. A few
     25 additional Capfs and completion utilities are provided by the [[https://github.com/minad/cape][Cape]] package.
     26 
     27 *NOTE*: Corfu uses child frames to show the popup and falls back to the default
     28 setting of the ~completion-in-region-function~ on non-graphical displays. If you
     29 want to use Corfu in the terminal, install the package [[https://codeberg.org/akib/emacs-corfu-terminal][corfu-terminal]], which
     30 provides an alternative overlay-based display.
     31 
     32 #+html: <img src="https://github.com/minad/corfu/blob/screenshots/light.png?raw=true">
     33 
     34 #+html: <img src="https://github.com/minad/corfu/blob/screenshots/dark.png?raw=true">
     35 
     36 #+html: <img src="https://github.com/minad/corfu/blob/screenshots/popupinfo-light.png?raw=true">
     37 
     38 #+html: <img src="https://github.com/minad/corfu/blob/screenshots/popupinfo-dark.png?raw=true">
     39 
     40 #+toc: headlines 8
     41 
     42 * Features
     43 
     44 - Timer-based auto-completions (/off/ by default, set ~corfu-auto~).
     45 - Popup display with scrollbar indicator and arrow key navigation.
     46 - The popup can be summoned explicitly by pressing =TAB= at any time.
     47 - The current candidate is inserted with =TAB= and selected with =RET=.
     48 - Candidates sorting by prefix, string length and alphabetically.
     49 - The selected candidate is previewed (configurable via ~corfu-preview-current~).
     50 - The selected candidate automatically committed on further input by default.
     51   (configurable via ~corfu-preview-current~).
     52 - The [[https://github.com/oantolin/orderless][Orderless]] completion style is supported. The filter string can contain
     53   arbitrary characters, after inserting a space via =M-SPC= (configurable via
     54   ~corfu-quit-at-boundary~ and ~corfu-separator~).
     55 - Deferred completion style highlighting for performance.
     56 - Support for candidate annotations (=annotation-function=, =affixation-function=).
     57 - Deprecated candidates are crossed out in the display.
     58 - Icons can be provided by an external package via margin formatter functions.
     59 - Rich set of extensions: Quick keys, Index keys, Sorting by history, Candidate
     60   documentation in echo area, popup or separate buffer
     61 
     62 * Installation and Configuration
     63 
     64 Corfu is available from [[https://elpa.gnu.org/packages/corfu.html][GNU ELPA]], such that it can be installed directly via
     65 ~package-install~. After installation, the global minor mode can be enabled with
     66 =M-x global-corfu-mode=. In order to configure Corfu and other packages in your
     67 init.el, you may want to use ~use-package~.
     68 
     69 Corfu is highly flexible and customizable via ~corfu-*~ customization variables,
     70 such that you can adapt it precisely to your requirements. However in order to
     71 quickly try out the Corfu completion package, it should be sufficient to
     72 activate ~global-corfu-mode~. You can experiment with manual completion for
     73 example in an Elisp buffer or in an Eshell or Shell buffer. For auto completion,
     74 set ~corfu-auto=t~ before turning on ~global-corfu-mode~.
     75 
     76 Here is an example configuration:
     77 
     78 #+begin_src emacs-lisp
     79   (use-package corfu
     80     ;; Optional customizations
     81     ;; :custom
     82     ;; (corfu-cycle t)                ;; Enable cycling for `corfu-next/previous'
     83     ;; (corfu-auto t)                 ;; Enable auto completion
     84     ;; (corfu-separator ?\s)          ;; Orderless field separator
     85     ;; (corfu-quit-at-boundary nil)   ;; Never quit at completion boundary
     86     ;; (corfu-quit-no-match nil)      ;; Never quit, even if there is no match
     87     ;; (corfu-preview-current nil)    ;; Disable current candidate preview
     88     ;; (corfu-preselect 'prompt)      ;; Preselect the prompt
     89     ;; (corfu-on-exact-match nil)     ;; Configure handling of exact matches
     90     ;; (corfu-scroll-margin 5)        ;; Use scroll margin
     91 
     92     ;; Enable Corfu only for certain modes.
     93     ;; :hook ((prog-mode . corfu-mode)
     94     ;;        (shell-mode . corfu-mode)
     95     ;;        (eshell-mode . corfu-mode))
     96 
     97     ;; Recommended: Enable Corfu globally.
     98     ;; This is recommended since Dabbrev can be used globally (M-/).
     99     ;; See also `corfu-exclude-modes'.
    100     :init
    101     (global-corfu-mode))
    102 
    103   ;; A few more useful configurations...
    104   (use-package emacs
    105     :init
    106     ;; TAB cycle if there are only few candidates
    107     (setq completion-cycle-threshold 3)
    108 
    109     ;; Emacs 28: Hide commands in M-x which do not apply to the current mode.
    110     ;; Corfu commands are hidden, since they are not supposed to be used via M-x.
    111     ;; (setq read-extended-command-predicate
    112     ;;       #'command-completion-default-include-p)
    113 
    114     ;; Enable indentation+completion using the TAB key.
    115     ;; `completion-at-point' is often bound to M-TAB.
    116     (setq tab-always-indent 'complete))
    117 #+end_src
    118 
    119 Dabbrev completion is based on =completion-in-region= and can be used with Corfu.
    120 You may want to swap the =dabbrev-completion= with the =dabbrev-expand= key for
    121 easier access, if you prefer completion. Also take a look at the =cape-dabbrev=
    122 completion at point function provided by my [[https://github.com/minad/cape][Cape]] package.
    123 
    124 #+begin_src emacs-lisp
    125   ;; Use Dabbrev with Corfu!
    126   (use-package dabbrev
    127     ;; Swap M-/ and C-M-/
    128     :bind (("M-/" . dabbrev-completion)
    129            ("C-M-/" . dabbrev-expand))
    130     ;; Other useful Dabbrev configurations.
    131     :custom
    132     (dabbrev-ignored-buffer-regexps '("\\.\\(?:pdf\\|jpe?g\\|png\\)\\'")))
    133 #+end_src
    134 
    135 If you start to configure the package more deeply, I recommend to give the
    136 Orderless completion style a try for filtering. Orderless completion is
    137 different from the familiar prefix TAB completion. Corfu can be used with the
    138 default completion styles. The use of Orderless is not a necessity.
    139 
    140 #+begin_src emacs-lisp
    141   ;; Optionally use the `orderless' completion style.
    142   (use-package orderless
    143     :init
    144     ;; Configure a custom style dispatcher (see the Consult wiki)
    145     ;; (setq orderless-style-dispatchers '(+orderless-dispatch)
    146     ;;       orderless-component-separator #'orderless-escapable-split-on-space)
    147     (setq completion-styles '(orderless basic)
    148           completion-category-defaults nil
    149           completion-category-overrides '((file (styles . (partial-completion))))))
    150 #+end_src
    151 
    152 The =basic= completion style is specified as fallback in addition to =orderless= in
    153 order to ensure that completion commands which rely on dynamic completion
    154 tables, e.g., ~completion-table-dynamic~ or ~completion-table-in-turn~, work
    155 correctly. See =+orderless-dispatch= in the [[https://github.com/minad/consult/wiki][Consult wiki]] for an advanced Orderless
    156 style dispatcher. Additionally enable =partial-completion= for file path
    157 expansion. =partial-completion= is important for file wildcard support. Multiple
    158 files can be opened at once with =find-file= if you enter a wildcard. You may also
    159 give the =initials= completion style a try.
    160 
    161 See also the [[https://github.com/minad/corfu/wiki][Corfu Wiki]] and the [[https://github.com/minad/cape][Cape manual]] for additional Capf configuration
    162 tips. The Eglot and Lsp-mode configurations are documented in the wiki. For more
    163 general documentation read the chapter about completion in the [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Completion.html][Emacs manual]]. If
    164 you want to create your own Capfs, you can find documentation about completion
    165 in the [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Completion.html][Elisp manual]].
    166 
    167 ** Auto completion
    168 
    169 Auto completion is disabled by default, but can be enabled by setting
    170 ~corfu-auto=t~. Furthermore you may want to configure Corfu to quit completion
    171 eagerly, such that the completion popup stays out of your way when it appeared
    172 unexpectedly.
    173 
    174 #+begin_src emacs-lisp
    175   ;; Enable auto completion and configure quitting
    176   (setq corfu-auto t
    177         corfu-quit-no-match 'separator) ;; or t
    178 #+end_src
    179 
    180 I recommend to experiment a bit with the various settings and key bindings to
    181 find a configuration which works for you. There is no one size fits all
    182 solution. Some people like auto completion, some like manual completion, some
    183 want to cycle with TAB and some with the arrow keys.
    184 
    185 In case you like aggressive auto completion settings, where the completion popup
    186 appears immediately, I recommend to use a cheap completion style like =basic=,
    187 which performs prefix filtering. In this case Corfu completion should still be
    188 very fast in buffers with efficient completion backends. You can try the
    189 following settings in an Elisp buffer or the Emacs scratch buffer.
    190 
    191 #+begin_src emacs-lisp
    192   ;; Aggressive completion, cheap prefix filtering.
    193   (setq-local corfu-auto t
    194               corfu-auto-delay 0
    195               corfu-auto-prefix 0
    196               completion-styles '(basic))
    197 #+end_src
    198 
    199 If you want to combine fast prefix filtering and Orderless filtering you can
    200 still do that by defining a custom Orderless completion style via
    201 =orderless-define-completion-style=. We use a custom style dispatcher, which
    202 enables prefix filtering for input shorter than 4 characters. Note that such a
    203 setup is quite advanced. Please refer to the Orderless documentation and source
    204 code for further details.
    205 
    206 #+begin_src emacs-lisp
    207   (defun orderless-fast-dispatch (word index total)
    208     (and (= index 0) (= total 1) (length< word 4)
    209          `(orderless-regexp . ,(concat "^" (regexp-quote word)))))
    210 
    211   (orderless-define-completion-style orderless-fast
    212     (orderless-style-dispatchers '(orderless-fast-dispatch))
    213     (orderless-matching-styles '(orderless-literal orderless-regexp)))
    214 
    215   (setq-local corfu-auto t
    216               corfu-auto-delay 0
    217               corfu-auto-prefix 0
    218               completion-styles '(orderless-fast))
    219 #+end_src
    220 
    221 ** Completing in the minibuffer
    222 
    223 Corfu can be used for completion in the minibuffer, since it relies on child
    224 frames to display the candidates. By default, ~global-corfu-mode~ does not
    225 activate ~corfu-mode~ in the minibuffer, to avoid interference with specialised
    226 minibuffer completion UIs like Vertico or Mct. However you may still want to
    227 enable Corfu completion for commands like ~M-:~ (~eval-expression~) or ~M-!~
    228 (~shell-command~), which read from the minibuffer. Activate ~corfu-mode~ only if
    229 ~completion-at-point~ is bound in the minibuffer-local keymap to achieve this
    230 effect.
    231 
    232 #+begin_src emacs-lisp
    233     (defun corfu-enable-in-minibuffer ()
    234       "Enable Corfu in the minibuffer if `completion-at-point' is bound."
    235       (when (where-is-internal #'completion-at-point (list (current-local-map)))
    236         ;; (setq-local corfu-auto nil) ;; Enable/disable auto completion
    237         (setq-local corfu-echo-delay nil ;; Disable automatic echo and popup
    238                     corfu-popupinfo-delay nil)
    239         (corfu-mode 1)))
    240     (add-hook 'minibuffer-setup-hook #'corfu-enable-in-minibuffer)
    241 #+end_src
    242 
    243 You can also enable Corfu more generally for every minibuffer, as long as no
    244 completion UI is active. In the following example we check for Mct and Vertico.
    245 Furthermore we ensure that Corfu is not enabled if a password is read from the
    246 minibuffer.
    247 
    248 #+begin_src emacs-lisp
    249   (defun corfu-enable-always-in-minibuffer ()
    250     "Enable Corfu in the minibuffer if Vertico/Mct are not active."
    251     (unless (or (bound-and-true-p mct--active)
    252                 (bound-and-true-p vertico--input)
    253                 (eq (current-local-map) read-passwd-map))
    254       ;; (setq-local corfu-auto nil) ;; Enable/disable auto completion
    255       (setq-local corfu-echo-delay nil ;; Disable automatic echo and popup
    256                   corfu-popupinfo-delay nil)
    257       (corfu-mode 1)))
    258   (add-hook 'minibuffer-setup-hook #'corfu-enable-always-in-minibuffer 1)
    259 #+end_src
    260 
    261 ** Completing in the Eshell or Shell
    262 
    263 When completing in the Eshell I recommend conservative local settings without
    264 auto completion, such that the completion behavior is similar to widely used
    265 shells like Bash, Zsh or Fish.
    266 
    267 #+begin_src emacs-lisp
    268   (add-hook 'eshell-mode-hook
    269             (lambda ()
    270               (setq-local corfu-auto nil)
    271               (corfu-mode)))
    272 #+end_src
    273 
    274 When pressing =RET= while the Corfu popup is visible, the ~corfu-insert~ command
    275 will be invoked. This command does inserts the currently selected candidate, but
    276 it does not send the prompt input to Eshell or the comint process. Therefore you
    277 often have to press =RET= twice which feels like an unnecessary double
    278 confirmation. Fortunately it is easy to improve this! In my configuration I
    279 define the advice ~corfu-send-shell~ which sends the candidate after insertion.
    280 
    281 #+begin_src emacs-lisp
    282   (defun corfu-send-shell (&rest _)
    283     "Send completion candidate when inside comint/eshell."
    284     (cond
    285      ((and (derived-mode-p 'eshell-mode) (fboundp 'eshell-send-input))
    286       (eshell-send-input))
    287      ((and (derived-mode-p 'comint-mode)  (fboundp 'comint-send-input))
    288       (comint-send-input))))
    289 
    290   (advice-add #'corfu-insert :after #'corfu-send-shell)
    291 #+end_src
    292 
    293 Shell completion uses the flexible Pcomplete mechanism internally, which allows
    294 you to program the completions per shell command. If you want to know more, look
    295 into the [[https://www.masteringemacs.org/article/pcomplete-context-sensitive-completion-emacs][blog post]], which shows how to configure Pcomplete for git commands.
    296 Since Emacs 29, Pcomplete offers the =pcomplete-from-help= function which parses
    297 the ~--help~ output of a command and produces completions. This functionality is
    298 similar to the Fish shell, which also takes advantage of ~--help~ to dynamically
    299 generate completions.
    300 
    301 Unfortunately Pcomplete had a few technical issues on Emacs 28 and older. We can
    302 work around the issues with the [[https://github.com/minad/cape][Cape]] library (Completion at point extensions).
    303 Cape provides wrappers which sanitize the Pcomplete function. If you use Emacs
    304 28 or older installing these advices is strongly recommend such that Pcomplete
    305 works properly. On Emacs 29 the advices are not necessary anymore, since almost
    306 all of the related bugs have been fixed. I therefore recommend to remove the
    307 advices on Emacs 29 and eventually report any remaining Pcomplete issues
    308 upstream, such that they can be fixed at the root.
    309 
    310 #+begin_src emacs-lisp
    311   ;; The advices are only needed on Emacs 28 and older.
    312   (when (< emacs-major-version 29)
    313     ;; Silence the pcomplete capf, no errors or messages!
    314     (advice-add 'pcomplete-completions-at-point :around #'cape-wrap-silent)
    315 
    316     ;; Ensure that pcomplete does not write to the buffer
    317     ;; and behaves as a pure `completion-at-point-function'.
    318     (advice-add 'pcomplete-completions-at-point :around #'cape-wrap-purify))
    319 #+end_src
    320 
    321 ** Orderless completion
    322 
    323 [[https://github.com/oantolin/orderless][Orderless]] is an advanced completion style that supports multi-component search
    324 filters separated by a configurable character (space, by default). Normally,
    325 entering characters like space which lie outside the completion region
    326 boundaries (words, typically) causes Corfu to quit. This behavior is helpful
    327 with auto-completion, which may pop-up when not desired, e.g. on entering a new
    328 variable name. Just keep typing and Corfu will get out of the way.
    329 
    330 But orderless search terms can contain arbitrary characters; they are also
    331 interpreted as regular expressions. To use orderless, set ~corfu-separator~ (a
    332 space, by default) to the primary character of your orderless component
    333 separator.
    334 
    335 Then, when a new orderless component is desired, use =M-SPC=
    336 (~corfu-insert-separator~) to enter the /first/ component separator in the input,
    337 and arbitrary orderless search terms and new separators can be entered
    338 thereafter.
    339 
    340 To treat the entire input as Orderless input, you can set the customization
    341 option ~corfu-quit-at-boundary=t~. This disables the predicate which checks if the
    342 current completion boundary has been left. In contrast, if you /always/ want to
    343 quit at the boundary, simply set ~corfu-quit-at-boundary=nil~. By default
    344 ~corfu-quit-at-boundary~ is set to ~separator~ which quits at completion boundaries
    345 as long as no separator has been inserted with ~corfu-insert-separator~.
    346 
    347 Finally, there exists the user option ~corfu-quit-no-match~ which is set to
    348 =separator= by default. With this setting Corfu stays alive as soon as you start
    349 advanced filtering with a ~corfu-separator~ even if there are no matches, for
    350 example due to a typo. As long as no separator character has been inserted with
    351 ~corfu-insert-separator~, Corfu will still quit if there are no matches. This
    352 ensures that the Corfu popup goes away quickly if completion is not possible.
    353 
    354 In the following we show two configurations, one which works best with auto
    355 completion and one which may work better with manual completion if you prefer to
    356 always use =SPC= to separate the Orderless components.
    357 
    358  #+begin_src emacs-lisp
    359    ;; Auto completion example
    360    (use-package corfu
    361      :custom
    362      (corfu-auto t)          ;; Enable auto completion
    363      ;; (corfu-separator ?_) ;; Set to orderless separator, if not using space
    364      :bind
    365      ;; Another key binding can be used, such as S-SPC.
    366      ;; (:map corfu-map ("M-SPC" . corfu-insert-separator))
    367      :init
    368      (global-corfu-mode))
    369 
    370    ;; Manual completion example
    371    (use-package corfu
    372      :custom
    373      ;; (corfu-separator ?_) ;; Set to orderless separator, if not using space
    374      :bind
    375      ;; Configure SPC for separator insertion
    376      (:map corfu-map ("SPC" . corfu-insert-separator))
    377      :init
    378      (global-corfu-mode))
    379 #+end_src
    380 
    381 ** TAB-and-Go completion
    382 
    383 You may be interested in configuring Corfu in TAB-and-Go style. Pressing TAB
    384 moves to the next candidate and further input will then commit the selection.
    385 Note that further input will not expand snippets or templates, which may not be
    386 desired but which leads overall to a more predictable behavior. In order to
    387 force snippet expansion, confirm a candidate explicitly with ~RET~.
    388 
    389 #+begin_src emacs-lisp
    390   (use-package corfu
    391     ;; TAB-and-Go customizations
    392     :custom
    393     (corfu-cycle t)           ;; Enable cycling for `corfu-next/previous'
    394     (corfu-preselect 'prompt) ;; Always preselect the prompt
    395 
    396     ;; Use TAB for cycling, default is `corfu-complete'.
    397     :bind
    398     (:map corfu-map
    399           ("TAB" . corfu-next)
    400           ([tab] . corfu-next)
    401           ("S-TAB" . corfu-previous)
    402           ([backtab] . corfu-previous))
    403 
    404     :init
    405     (global-corfu-mode))
    406 #+end_src
    407 
    408 ** Transfer completion to the minibuffer
    409 
    410 Sometimes it is useful to transfer the Corfu completion session to the
    411 minibuffer, since the minibuffer offers richer interaction features. In
    412 particular, [[https://github.com/oantolin/embark][Embark]] is available in the minibuffer, such that you can act on the
    413 candidates or export/collect the candidates to a separate buffer. We could add
    414 Corfu support to Embark in the future, such that export/collect is possible
    415 directly from Corfu. But in my opinion having the ability to transfer the Corfu
    416 completion to the minibuffer is an even better feature, since further completion
    417 can be performed there.
    418 
    419 The command ~corfu-move-to-minibuffer~ is defined here in terms of
    420 ~consult-completion-in-region~, which uses the minibuffer completion UI via
    421 ~completing-read~.
    422 
    423 #+begin_src emacs-lisp
    424   (defun corfu-move-to-minibuffer ()
    425     (interactive)
    426     (let ((completion-extra-properties corfu--extra)
    427           completion-cycle-threshold completion-cycling)
    428       (apply #'consult-completion-in-region completion-in-region--data)))
    429   (keymap-set corfu-map "M-m" #'corfu-move-to-minibuffer)
    430 #+end_src
    431 
    432 * Key bindings
    433 
    434 Corfu uses a transient keymap ~corfu-map~ which is active while the popup is
    435 shown. The keymap defines the following remappings and bindings:
    436 
    437 - ~move-beginning-of-line~ -> ~corfu-prompt-beginning~
    438 - ~move-end-of-line~ -> ~corfu-prompt-end~
    439 - ~beginning-of-buffer~ -> ~corfu-first~
    440 - ~end-of-buffer~ -> ~corfu-last~
    441 - ~scroll-down-command~ -> ~corfu-scroll-down~
    442 - ~scroll-up-command~ -> ~corfu-scroll-up~
    443 - ~next-line~, =down=, =M-n= -> ~corfu-next~
    444 - ~previous-line~, =up=, =M-p= -> ~corfu-previous~
    445 - ~completion-at-point~, =TAB= -> ~corfu-complete~
    446 - =RET= -> ~corfu-insert~
    447 - =M-g= -> ~corfu-info-location~
    448 - =M-h= -> ~corfu-info-documentation~
    449 - =M-SPC= -> ~corfu-insert-separator~
    450 - =C-g= -> ~corfu-quit~
    451 - ~keyboard-escape-quit~ -> ~corfu-reset~
    452 
    453 * Extensions
    454 :properties:
    455 :custom_id: extensions
    456 :end:
    457 
    458 We maintain small extension packages to Corfu in this repository in the
    459 subdirectory [[https://github.com/minad/corfu/tree/main/extensions][extensions/]]. The extensions are installed together with Corfu if
    460 you pull the package from ELPA. The extensions are inactive by default and can
    461 be enabled manually if desired. Furthermore it is possible to install all of the
    462 files separately, both ~corfu.el~ and the ~corfu-*.el~ extensions. Currently the
    463 following extensions come with the Corfu ELPA package:
    464 
    465 - [[https://github.com/minad/corfu/blob/main/extensions/corfu-echo.el][corfu-echo]]: =corfu-echo-mode= displays a brief candidate documentation in the
    466   echo area.
    467 - [[https://github.com/minad/corfu/blob/main/extensions/corfu-history.el][corfu-history]]: =corfu-history-mode= remembers selected candidates and sorts the
    468   candidates by their history position.
    469 - [[https://github.com/minad/corfu/blob/main/extensions/corfu-indexed.el][corfu-indexed]]: =corfu-indexed-mode= allows you to select indexed candidates with
    470   prefix arguments.
    471 - [[https://github.com/minad/corfu/blob/main/extensions/corfu-info.el][corfu-info]]: Actions to access the candidate location and documentation.
    472 - [[https://github.com/minad/corfu/blob/main/extensions/corfu-popupinfo.el][corfu-popupinfo]]: Display candidate documentation or source in a popup next to
    473   the candidate menu.
    474 - [[https://github.com/minad/corfu/blob/main/extensions/corfu-quick.el][corfu-quick]]: Commands to select using Avy-style quick keys.
    475 
    476 See the Commentary of those files for configuration details.
    477 
    478 * Complementary packages
    479 
    480 Corfu works well together with all packages providing code completion via the
    481 ~completion-at-point-functions~. Many modes and packages already provide a Capf
    482 out of the box. Nevertheless you may want to look into complementary packages to
    483 enhance your setup.
    484 
    485 - [[https://codeberg.org/akib/emacs-corfu-terminal][corfu-terminal]]: The corfu-terminal package provides an overlay-based display
    486   for Corfu, such that you can use Corfu in terminal Emacs.
    487 
    488 - [[https://github.com/oantolin/orderless][Orderless]]: Corfu supports completion styles, including the advanced
    489   [[https://github.com/oantolin/orderless][Orderless]] completion style, where the filtering expressions are separated by
    490   spaces or another character (see ~corfu-separator~).
    491 
    492 - [[https://github.com/minad/cape][Cape]]: Additional Capf backends and =completion-in-region= commands
    493   are provided by the [[https://github.com/minad/cape][Cape]] package. Among others, the package supplies a file
    494   path and a Dabbrev completion backend. Cape provides the ~cape-company-to-capf~
    495   adapter to reuse Company backends in Corfu. Furthermore the function
    496   ~cape-super-capf~ can merge multiple Capfs, such that the candidates of multiple
    497   Capfs are displayed together at the same time.
    498 
    499 - [[https://github.com/jdtsmith/kind-icon][kind-icon]]: Icons are supported by Corfu via an external package. For example
    500   the [[https://github.com/jdtsmith/kind-icon][kind-icon]] package provides beautifully styled SVG icons based on
    501   monochromatic icon sets like material design.
    502 
    503 - [[https://github.com/minad/tempel][Tempel]]: Tiny template/snippet package with templates in Lisp syntax, which
    504   can be used in conjunction with Corfu.
    505 
    506 - [[https://github.com/minad/vertico][Vertico]]: You may also want to look into my [[https://github.com/minad/vertico][Vertico]] package. Vertico is the
    507   minibuffer completion counterpart of Corfu.
    508 
    509 * Alternatives
    510 
    511 - [[https://github.com/company-mode/company-mode][Company]]: Company is a widely used and mature completion package, which
    512   implements a similar interaction model and popup UI as Corfu. While Corfu
    513   relies exclusively on the standard Emacs completion API (Capfs), Company
    514   defines its own API for the backends. Company includes its completion
    515   backends, which are incompatible with the Emacs completion infrastructure. As
    516   a result of this design, Company is a more complex package than Corfu. Company
    517   by default uses overlays for the popup in contrast to the child frames used by
    518   Corfu. Overall both packages work well, but Company integrates less tightly
    519   with Emacs. The ~completion-styles~ support is more limited and the
    520   ~completion-at-point~ command and the ~completion-in-region~ function do not
    521   invoke Company.
    522 
    523 - [[https://github.com/minad/consult][consult-completion-in-region]]: The Consult package provides the function
    524   ~consult-completion-in-region~ which can be set as ~completion-in-region-function~
    525   such that it handles ~completion-at-point~. The function works by transferring
    526   the in-buffer completion to the minibuffer. In the minibuffer, the minibuffer
    527   completion UI, for example [[https://github.com/minad/vertico][Vertico]] takes over. If you prefer to perform all
    528   your completions in the minibuffer ~consult-completion-in-region~ is your best
    529   option.
    530 
    531 * Contributions
    532 
    533 Since this package is part of [[https://elpa.gnu.org/packages/corfu.html][GNU ELPA]] contributions require a copyright
    534 assignment to the FSF.