Enable corfu in minibuffer if vertico not active

This commit is contained in:
Evie Litherland-Smith 2023-12-04 09:38:41 +00:00
parent eb60d4d767
commit 64a7497515
2 changed files with 72 additions and 24 deletions

View file

@ -513,9 +513,10 @@
:ensure t :ensure t
:custom :custom
(vertico-cycle t) (vertico-cycle t)
:init
(vertico-mode)
:config :config
(require 'vertico-directory) (require 'vertico-directory))
(vertico-mode +1))
(use-package marginalia (use-package marginalia
:ensure t :ensure t
@ -538,21 +539,44 @@
(corfu-cycle t) (corfu-cycle t)
(corfu-auto t) (corfu-auto t)
(corfu-auto-prefix 3) (corfu-auto-prefix 3)
:config (corfu-quit-no-match 'separator)
(corfu-quit-at-boundary 'separator)
(corfu-preselect 'directory)
:bind (:map corfu-map
("RET" . nil))
:init
(global-corfu-mode +1) (global-corfu-mode +1)
:config
(when (require 'corfu-popupinfo nil :noerror) (when (require 'corfu-popupinfo nil :noerror)
(corfu-popupinfo-mode 1) (corfu-popupinfo-mode +1)
(eldoc-add-command #'corfu-insert)
(keymap-set corfu-map "M-p" #'corfu-popupinfo-scroll-down) (keymap-set corfu-map "M-p" #'corfu-popupinfo-scroll-down)
(keymap-set corfu-map "M-n" #'corfu-popupinfo-scroll-up) (keymap-set corfu-map "M-n" #'corfu-popupinfo-scroll-up)
(keymap-set corfu-map "M-d" #'corfu-popupinfo-toggle)) (keymap-set corfu-map "M-d" #'corfu-popupinfo-toggle))
(defun crafted-completion-corfu-eshell ()
"Special settings for when using corfu with eshell." (defun corfu-enable-always-in-minibuffer ()
(setq-local corfu-quit-at-boundary t "Enable Corfu in the minibuffer if Vertico is not active."
corfu-quit-no-match t (unless (or (bound-and-true-p vertico--input)
corfu-auto nil) (eq (current-local-map) read-passwd-map))
(corfu-mode)) (setq-local corfu-echo-delay nil ;; Disable automatic echo and popup
(add-hook 'eshell-mode-hook #'crafted-completion-corfu-eshell)) corfu-auto nil ;; Enable/disable auto completion
corfu-popupinfo-delay nil)
(corfu-mode +1)))
(add-hook 'minibuffer-setup-hook #'corfu-enable-always-in-minibuffer 1)
(add-hook 'eshell-mode-hook
(lambda ()
(setq-local corfu-auto nil)
(corfu-mode)))
(defun corfu-send-shell (&rest _)
"Send completion candidate when inside comint/eshell."
(cond
((and (derived-mode-p 'eshell-mode) (fboundp 'eshell-send-input))
(eshell-send-input))
((and (derived-mode-p 'comint-mode) (fboundp 'comint-send-input))
(comint-send-input))))
(advice-add #'corfu-insert :after #'corfu-send-shell))
(use-package cape (use-package cape
:ensure t :ensure t

View file

@ -621,9 +621,10 @@ For reference information, see [[https://orgmode.com][Org-mode website]]
:ensure t :ensure t
:custom :custom
(vertico-cycle t) (vertico-cycle t)
:init
(vertico-mode)
:config :config
(require 'vertico-directory) (require 'vertico-directory))
(vertico-mode +1))
#+end_src #+end_src
*** Marginalia *** Marginalia
@ -655,21 +656,44 @@ For reference information, see [[https://orgmode.com][Org-mode website]]
(corfu-cycle t) (corfu-cycle t)
(corfu-auto t) (corfu-auto t)
(corfu-auto-prefix 3) (corfu-auto-prefix 3)
:config (corfu-quit-no-match 'separator)
(corfu-quit-at-boundary 'separator)
(corfu-preselect 'directory)
:bind (:map corfu-map
("RET" . nil))
:init
(global-corfu-mode +1) (global-corfu-mode +1)
:config
(when (require 'corfu-popupinfo nil :noerror) (when (require 'corfu-popupinfo nil :noerror)
(corfu-popupinfo-mode 1) (corfu-popupinfo-mode +1)
(eldoc-add-command #'corfu-insert)
(keymap-set corfu-map "M-p" #'corfu-popupinfo-scroll-down) (keymap-set corfu-map "M-p" #'corfu-popupinfo-scroll-down)
(keymap-set corfu-map "M-n" #'corfu-popupinfo-scroll-up) (keymap-set corfu-map "M-n" #'corfu-popupinfo-scroll-up)
(keymap-set corfu-map "M-d" #'corfu-popupinfo-toggle)) (keymap-set corfu-map "M-d" #'corfu-popupinfo-toggle))
(defun crafted-completion-corfu-eshell ()
"Special settings for when using corfu with eshell." (defun corfu-enable-always-in-minibuffer ()
(setq-local corfu-quit-at-boundary t "Enable Corfu in the minibuffer if Vertico is not active."
corfu-quit-no-match t (unless (or (bound-and-true-p vertico--input)
corfu-auto nil) (eq (current-local-map) read-passwd-map))
(corfu-mode)) (setq-local corfu-echo-delay nil ;; Disable automatic echo and popup
(add-hook 'eshell-mode-hook #'crafted-completion-corfu-eshell)) corfu-auto nil ;; Enable/disable auto completion
corfu-popupinfo-delay nil)
(corfu-mode +1)))
(add-hook 'minibuffer-setup-hook #'corfu-enable-always-in-minibuffer 1)
(add-hook 'eshell-mode-hook
(lambda ()
(setq-local corfu-auto nil)
(corfu-mode)))
(defun corfu-send-shell (&rest _)
"Send completion candidate when inside comint/eshell."
(cond
((and (derived-mode-p 'eshell-mode) (fboundp 'eshell-send-input))
(eshell-send-input))
((and (derived-mode-p 'comint-mode) (fboundp 'comint-send-input))
(comint-send-input))))
(advice-add #'corfu-insert :after #'corfu-send-shell))
(use-package cape (use-package cape
:ensure t :ensure t