Commit f411d9bb9f65

Vincent Demeester <vincent@sbr.pm>
2023-11-15 22:34:05
tools/emacs: configure corfu
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 359abab
Changed files (1)
tools
tools/emacs/config/config-completion.el
@@ -94,5 +94,26 @@
   :unless noninteractive
   :config
   (marginalia-mode 1))
+
+(use-package corfu
+  :unless noninteractive
+  :config
+  (global-corfu-mode 1)
+  (corfu-popupinfo-mode 1)
+    ;; Sort by input history (no need to modify `corfu-sort-function').
+  (with-eval-after-load 'savehist
+    (corfu-history-mode 1)
+    (add-to-list 'savehist-additional-variables 'corfu-history))
+
+  ;; Adapted from Corfu's manual.
+  (defun contrib/corfu-enable-always-in-minibuffer ()
+    "Enable Corfu in the minibuffer if MCT or Vertico is not active.
+Useful for prompts such as `eval-expression' and `shell-command'."
+    (unless (or (bound-and-true-p vertico--input)
+                (bound-and-true-p mct--active))
+      (corfu-mode 1)))
+
+  (add-hook 'minibuffer-setup-hook #'contrib/corfu-enable-always-in-minibuffer 1))
+
 (provide 'config-completion)
 ;;; config-completion.el ends here