dotfiles/emacs-lisp/corfu.org
main 3638492702
Emacs Org
Signed-off-by: main <magic_rb@redalder.org>
2022-02-20 15:26:48 +01:00

2.3 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
      (corfu-global-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))

  (add-hook 'prog-mode-hook 'cape-setup-capf-prog)
  (add-hook 'text-mode-hook 'cape-setup-capf-text)

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

  (use-package lsp-mode
    :defer t
    :after cape
    :config
    (add-hook 'lsp-mode-hook 'cape-setup-capf))