Completion frameworks

This commit is contained in:
Aleksandr Lebedev 2025-03-10 16:11:08 +01:00
parent 2d7e8f863a
commit a40bbd4be4

View file

@ -78,6 +78,8 @@
- [[#persist-state][Persist state]]
- [[#buffer-move][Buffer Move]]
- [[#completions][Completions]]
- [[#corfu][Corfu]]
- [[#cape][Cape]]
- [[#vertico][Vertico]]
- [[#orderless][Orderless]]
- [[#fido-mode][Fido-mode]]
@ -1330,6 +1332,69 @@ one, an error is signaled."
(select-window other-win))))
#+end_src
* Completions
** Corfu
#+begin_src emacs-lisp
(use-package corfu
:ensure t
;; Optional customizations
:custom
(corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
(corfu-auto t)
(corfu-auto-prefix 2)
(corfu-quit-at-boundary 'separator)
(corfu-echo-documentation 0.25)
(corfu-preselect-first nil)
;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match
;; (corfu-preview-current nil) ;; Disable current candidate preview
;; (corfu-preselect 'prompt) ;; Preselect the prompt
;; (corfu-on-exact-match nil) ;; Configure handling of exact matches
;; Enable Corfu only for certain modes. See also `global-corfu-modes'.
;; :hook ((prog-mode . corfu-mode)
;; (shell-mode . corfu-mode)
;; (eshell-mode . corfu-mode))
:bind (:map corfu-map
("M-SPC" . corfu-insert-separator)
("RET" . nil)
("TAB" . corfu-next)
([tab] . corfu-next)
("SHIFT-TAB" . corfu-previous)
[backtab] . corfu-previous
("S-<return>" . corfu-insert))
;; Recommended: Enable Corfu globally. This is recommended since Dabbrev can
;; be used globally (M-/). See also the customization variable
;; `global-corfu-modes' to exclude certain modes.
:init
(global-corfu-mode))
;; A few more useful configurations...
(use-package emacs
:custom
;; TAB cycle if there are only few candidates
;; (completion-cycle-threshold 3)
;; Enable indentation+completion using the TAB key.
;; `completion-at-point' is often bound to M-TAB.
(tab-always-indent 'complete)
;; Emacs 30 and newer: Disable Ispell completion function.
;; Try `cape-dict' as an alternative.
(text-mode-ispell-word-completion nil)
;; Hide commands in M-x which do not apply to the current mode. Corfu
;; commands are hidden, since they are not used via M-x. This setting is
;; useful beyond Corfu.
(read-extended-command-predicate #'command-completion-default-include-p))
#+end_src
** Cape
#+begin_src emacs-lisp
(use-package cape
:ensure t
:defer 10
:init
(add-to-list 'completion-at-point-functions #'cape-file))
#+end_src
** Vertico
[[https://github.com/minad/vertico][Vertico]] provides a performant and minimalistic vertical completion UI based on the default completion system.
#+begin_src emacs-lisp