diff options
| author | Eugene Triguba <hello@eugenetriguba.com> | 2026-04-04 10:37:19 -0400 |
|---|---|---|
| committer | Eugene Triguba <hello@eugenetriguba.com> | 2026-04-04 10:37:19 -0400 |
| commit | ca9f655c01a6f752a9bc47b50f4aa83c3ecc2f4f (patch) | |
| tree | 9617356ba2d76af4f29a558d4f09d01e6294ccfd /.emacs.d/modules/et-completion.el | |
| parent | Remove extra comments in elisp template (diff) | |
| download | dotfiles-ca9f655c01a6f752a9bc47b50f4aa83c3ecc2f4f.zip | |
Add completion-at-point configuration with corfu
Diffstat (limited to '.emacs.d/modules/et-completion.el')
| -rw-r--r-- | .emacs.d/modules/et-completion.el | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/.emacs.d/modules/et-completion.el b/.emacs.d/modules/et-completion.el new file mode 100644 index 0000000..e0fc230 --- /dev/null +++ b/.emacs.d/modules/et-completion.el @@ -0,0 +1,83 @@ +;;; et-completion.el --- Enhance the Emacs completion behavior -*- lexical-binding: t; -*- +;; +;;; Commentary: +;; +;;; Code: + +;; Add a vertical completion UI +(use-package vertico + :custom + (vertico-cycle t) + :init + (vertico-mode)) + +;; Adjust completion search behavior +(use-package orderless + :ensure t + :custom + (completion-styles '(orderless basic)) + (completion-category-overrides '((file (styles partial-completion)))) + (completion-pcm-leading-wildcard t)) + +;; Persist history over emacs restarts. +;; This allows vertico to sort by history position. +(use-package savehist + :init + (savehist-mode)) + +;; Add documentation alongside the completion items +(use-package marginalia + :init + (marginalia-mode)) + +(use-package corfu + :custom + (corfu-cycle t) ;; Enable cycling for `corfu-next/previous' + ;; (corfu-quit-at-boundary nil) ;; Never quit at completion boundary + ;; (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 'insert) ;; Configure handling of exact matches + (corfu-popupinfo-delay '(0.5 . 0.2)) ;; (first-show . subsequent) + (corfu-popupinfo-max-height 15) + (corfu-auto t) + (corfu-auto-delay 0.2) + (corfu-auto-trigger ".") + (corfu-quit-no-match 'separator) + + :init + (global-corfu-mode) + (corfu-history-mode) + (corfu-popupinfo-mode)) + +(use-package dabbrev + ;; Swap M-/ and C-M-/ + :bind (("M-/" . dabbrev-completion) + ("C-M-/" . dabbrev-expand)) + :config + (add-to-list 'dabbrev-ignored-buffer-regexps "\\` ") + (add-to-list 'dabbrev-ignored-buffer-modes 'authinfo-mode) + (add-to-list 'dabbrev-ignored-buffer-modes 'doc-view-mode) + (add-to-list 'dabbrev-ignored-buffer-modes 'pdf-view-mode) + (add-to-list 'dabbrev-ignored-buffer-modes 'tags-table-mode)) + +(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)) + +(provide 'et-completion) +;;; et-completion.el ends here |