From 8308d63f20923616891907d0bb5fabc1acb68cde Mon Sep 17 00:00:00 2001 From: jao Date: Fri, 22 Jul 2022 03:24:47 +0100 Subject: corfu config --- custom/jao-custom-completion.el | 47 ++++++++++++++++++++++++++++++++++++++++- custom/jao-custom-gnus.el | 1 + 2 files changed, 47 insertions(+), 1 deletion(-) (limited to 'custom') diff --git a/custom/jao-custom-completion.el b/custom/jao-custom-completion.el index 7a604e4..0e36fcc 100644 --- a/custom/jao-custom-completion.el +++ b/custom/jao-custom-completion.el @@ -126,7 +126,52 @@ ("RET" . company-complete-selection)) :diminish) -(unless nil (display-graphic-p) (global-company-mode 1)) +(unless (display-graphic-p) (global-company-mode 1)) + +;;; corfu +(use-package corfu + :ensure t + :init (setq corfu-echo-documentation 0.25 + corfu-cycle t + corfu-count 15 + corfu-quit-no-match t + corfu-auto t + corfu-commit-predicate nil + corfu-preview-current nil + corfu-preselect-first t + corfu-min-width 20 + corfu-max-width 100) + :config + + ;; show eldoc string immediately after accepted completion too + (with-eval-after-load "eldoc" + (eldoc-add-command-completions "corfu-")) + + (defun jao-corfu--active-p () + (and (>= corfu--index 0) (/= corfu--index corfu--preselect))) + + (defun jao-corfu-quit-or-insert () + (interactive) + (if (jao-corfu--active-p) (corfu-insert) (corfu-quit))) + + (defun jao-corfu-quit-or-previous () + (interactive) + (if (jao-corfu--active-p) + (corfu-previous) + (corfu-quit) + (previous-line))) + + :bind (:map corfu-map + ("C-" . corfu-insert) + ("\r" . jao-corfu-quit-or-insert) + ("C-p" . jao-corfu-quit-or-previous))) + +(defun corfu-in-minibuffer () + (when (not (bound-and-true-p vertico--input)) (corfu-mode 1))) + +(add-hook 'minibuffer-setup-hook #'corfu-in-minibuffer 1) + +(when (display-graphic-p) (global-corfu-mode 1)) ;;; vertico (use-package vertico diff --git a/custom/jao-custom-gnus.el b/custom/jao-custom-gnus.el index f415f63..d012773 100644 --- a/custom/jao-custom-gnus.el +++ b/custom/jao-custom-gnus.el @@ -390,6 +390,7 @@ (add-hook 'gnus-select-group-hook 'gnus-group-set-timestamp) (add-hook 'gnus-group-mode-hook 'gnus-topic-mode) + ;;;; open mail file in gnus (defun jao-gnus-file-to-group (file &optional maildir newsdir m-server n-server) "Compute the Gnus group name from the given file name. -- cgit v1.2.3