2022-02-20 15:26:48 +01:00
:PROPERTIES:
:ID: a4eab1d7-8928-438e-9ccc-1e3a65765534
:END:
#+title : Corfu
#+filetags : emacs-load
2022-07-31 11:03:59 +02:00
# SPDX-FileCopyrightText: 2022 Richard Brežák <richard@brezak.sk>
#
# SPDX-License-Identifier: LGPL-3.0-or-later
2022-02-20 15:26:48 +01:00
#+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
2022-05-23 08:31:53 +02:00
(global-corfu-mode))
2022-02-20 15:26:48 +01:00
#+end_src
* Company
#+begin_src emacs-lisp :noweb yes :exports none
(use-package company
:defer t
:init
<<company-global-modes >>)
#+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
2023-01-15 01:16:04 +01:00
(use-package corfu-lsp-mode
:no-require t
:after (lsp-mode corfu)
2022-02-20 15:26:48 +01:00
:init
<<lsp-completion-provider >>)
#+end_src
Make ~lsp-mode~ not turn on ~company~ first thing after start, so annoying.
#+name : lsp-completion-provider
2023-01-15 01:16:04 +01:00
#+begin_src emacs-lisp :tangle no
2022-02-20 15:26:48 +01:00
(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
<<cape-hooks >>)
#+end_src
Hook ~cape~ onto both ~text-mode~ and ~prog-mode~ .
#+name : cape-hooks
2023-01-15 01:16:04 +01:00
#+begin_src emacs-lisp :tangle no
2022-02-20 15:26:48 +01:00
(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))
2023-01-15 01:16:04 +01:00
:hook
((prog-mode . cape-setup-capf-prog)
(text-mode . cape-setup-capf-text))
2022-02-20 15:26:48 +01:00
#+end_src
~lsp-mode~ completely wipes ~completion-at-point-functions~ , so we need re-add ~cape~ after it removes everything.
#+begin_src emacs-lisp
2023-01-15 01:16:04 +01:00
(use-package cape-lsp-mode
:no-require t
:after (cape lsp-mode)
:hook
((lsp-mode . 'cape-setup-capf)))
2022-02-20 15:26:48 +01:00
#+end_src