;;; et-completion.el --- Enhance the Emacs completion behavior -*- lexical-binding: t; -*- ;;; Commentary: ;;; Code: ;; Add a vertical completion UI (use-package vertico :ensure t :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 :ensure t :init (marginalia-mode)) ;; Add completion at point (use-package corfu :ensure t :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-prefix 2) ;; trigger after 2 chars (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)) (use-package consult :ensure t :bind (("C-x b" . consult-buffer) ("M-y" . consult-yank-pop) ("M-g i" . consult-imenu) ("M-s l" . consult-line) ("M-s r" . consult-ripgrep) ("M-s f" . consult-fd)) :hook (completion-list-mode . consult-preview-at-point-mode)) (use-package embark :ensure t :bind (("C-." . embark-act) ("C-;" . embark-dwim) ("C-h B" . embark-bindings)) :init (setq prefix-help-command #'embark-prefix-help-command)) (use-package embark-consult :hook (embark-collect-mode . consult-preview-at-point-mode)) (provide 'et-completion) ;;; et-completion.el ends here