:PROPERTIES: :ID: a4eab1d7-8928-438e-9ccc-1e3a65765534 :END: #+title: Corfu #+filetags: emacs-load # SPDX-FileCopyrightText: 2022 Richard Brežák # # SPDX-License-Identifier: LGPL-3.0-or-later #+begin_quote Corfu enhances completion at point with a small completion popup. The current candidates are shown in a popup below or above the point. Corfu is the minimalistic completion-in-region counterpart of the Vertico minibuffer UI. #+end_quote #+begin_src emacs-lisp (use-package corfu :straight t :custom (corfu-separator ?\s) ;; M-SPC :general ("C-c c" 'completion-at-point) :init (global-corfu-mode)) #+end_src * Company #+begin_src emacs-lisp :noweb yes :exports none (use-package company :defer t :init <>) #+end_src Disable ~company~ globally, because company enables itself... #+name: company-init #+begin_src emacs-lisp (setq company-global-modes nil) #+end_src * LSP Mode #+begin_src emacs-lisp :noweb yes :exports none (use-package corfu-lsp-mode :no-require t :after (lsp-mode corfu) :init <>) #+end_src Make ~lsp-mode~ not turn on ~company~ first thing after start, so annoying. #+name: lsp-completion-provider #+begin_src emacs-lisp :tangle no (setq lsp-completion-provider :none) #+end_src * Cape ~cape~ provides useful ~capfs~, such as file and ispell completion, stuff that ~company~ has built-in. #+begin_src emacs-lisp :noweb yes :exports none (use-package cape :straight t :after (corfu) :init <>) #+end_src Hook ~cape~ onto both ~text-mode~ and ~prog-mode~. #+name: cape-hooks #+begin_src emacs-lisp :tangle no (defun cape-setup-capf-prog () "Setup cape completions for prog-mode" (cape-setup-capf)) (defun cape-setup-capf-text () "Setup cape completions for text-mode" (add-hook 'completion-at-point-functions #'cape-ispell) (cape-setup-capf)) (defun cape-setup-capf () "Setup cape completions" (add-hook 'completion-at-point-functions #'cape-file) (add-hook 'completion-at-point-functions #'cape-tex)) :hook ((prog-mode . cape-setup-capf-prog) (text-mode . cape-setup-capf-text)) #+end_src ~lsp-mode~ completely wipes ~completion-at-point-functions~, so we need re-add ~cape~ after it removes everything. #+begin_src emacs-lisp (use-package cape-lsp-mode :no-require t :after (cape lsp-mode) :hook ((lsp-mode . #'cape-setup-capf))) #+end_src