diff options
Diffstat (limited to 'custom/jao-custom-completion.el')
-rw-r--r-- | custom/jao-custom-completion.el | 47 |
1 files changed, 46 insertions, 1 deletions
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-<return>" . 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 |