dotfiles/emacs-lisp/corfu.org
main 5bed3b8355
Note review, using el.secretario
Signed-off-by: main <magic_rb@redalder.org>
2023-01-15 01:16:04 +01:00

2.5 KiB

Corfu

#

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.

    (use-package corfu
      :straight t
      :custom
      (corfu-separator ?\s) ;; M-SPC
      :general
      ("C-c c" 'completion-at-point)
      :init
      (global-corfu-mode))

Company

Disable company globally, because company enables itself…

  (setq company-global-modes nil)

LSP Mode

Make lsp-mode not turn on company first thing after start, so annoying.

  (setq lsp-completion-provider :none)

Cape

cape provides useful capfs, such as file and ispell completion, stuff that company has built-in.

Hook cape onto both text-mode and prog-mode.

  (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))

lsp-mode completely wipes completion-at-point-functions, so we need re-add cape after it removes everything.

  (use-package cape-lsp-mode
    :no-require t
    :after (cape lsp-mode)
    :hook
    ((lsp-mode . 'cape-setup-capf)))