From 38af445c33527f69504a060dffa0c784fa032e76 Mon Sep 17 00:00:00 2001 From: Kiana Sheibani Date: Thu, 13 Jun 2024 14:30:06 -0400 Subject: [PATCH] Switch to corfu over company --- config.org | 81 ++++++------------------------------------------------ 1 file changed, 8 insertions(+), 73 deletions(-) diff --git a/config.org b/config.org index bb5d654..67645ec 100644 --- a/config.org +++ b/config.org @@ -810,7 +810,7 @@ I'm a big fan of the Vertico ecosystem, as it's lightweight and easy to use. Let #+begin_src emacs-lisp :completion (vertico +icons) -(company +childframe) +(corfu +icons +orderless) #+end_src ** Checkers @@ -1441,81 +1441,16 @@ Our ~package!~ declarations go in ~packages.el~, which must not be byte-compiled Everything else goes in ~config.el~, which is managed by [[*=confpkg=][confpkg]] as outlined earlier. -** Company +** Corfu -#+call: confpkg("Pkg: company") - -*** Bindings - -When Company is active, its keybindings overshadow the default ones, meaning keys like =RET= no longer work. To prevent this from happening, let's rebind ~company-complete-selection~ to =TAB= (less useful in the middle of typing), and only allow =RET= to be used if Company has been explicitly interacted with. +#+call: confpkg("Pkg: corfu") #+begin_src emacs-lisp -(let ((item - `(menu-item nil company-complete-selection - :filter ,(lambda (cmd) - (when (company-explicit-action-p) - cmd))))) - (map! :after company - :map company-active-map - "RET" item - "" item - "TAB" #'company-complete-selection - "" #'company-complete-selection - "S-TAB" #'company-complete-common)) -#+end_src - -*** Spell Correction - -#+call: confpkg("Pkg: company-spell") - -I've been having problems with ~company-ispell~, mainly due to Ispell requiring a text-based dictionary (unlike Aspell, which uses a binary dictionary). So let's switch to ~company-spell~: - -#+begin_src emacs-lisp :tangle packages.el -(package! company-spell) -#+end_src - -#+begin_src emacs-lisp -(after! company-spell - (map! :map evil-insert-state-map - "C-x s" #'company-spell)) -#+end_src - -We should make sure that ~company-spell~ uses Ispell's personal dictionary too: - -#+begin_src emacs-lisp -(after! (company-spell ispell) - (setq company-spell-args - (concat company-spell-args " -p " ispell-personal-dictionary))) -#+end_src - -*** Icons - -The ~company-box~ front-end adds support for icons, but there aren't many providers for them, especially in text. We'll add two new icon providers: - -- ~~/company-box-icons--text~, which directly targets the output of ~company-spell~ -- ~~/company-box-icons--spell~, which is a fallback for all text completions - -#+begin_src emacs-lisp -;; Mark candidates from `company-spell' using a text property -(defadvice! ~/company-spell-text-property (words) - :filter-return #'company-spell-lookup-words - (dolist (word words) - (put-text-property 0 1 'spell-completion-item t word)) - words) - -(defun ~/company-box-icons--spell (candidate) - (when (get-text-property 0 'spell-completion-item candidate) - 'Text)) - -(defun ~/company-box-icons--text (candidate) - (when (derived-mode-p 'text-mode) 'Text)) - -(after! company-box - (pushnew! company-box-icons-functions #'~/company-box-icons--text) - ;; `~/company-box-icons--text' is a fallback, so it has to go at the end of - ;; the list - (setq company-box-icons-functions - (append company-box-icons-functions '(~/company-box-icons--text)))) +(after! corfu + ;; I don't really use TAB very often, so prefer other actions + (setq +corfu-want-tab-prefer-navigating-snippets t + +corfu-want-tab-prefer-expand-snippets t + +corfu-want-tab-prefer-navigating-org-tables t)) #+end_src ** Eldoc