Complete overhaul of corfu configuration and completion in general

This commit is contained in:
MitchMarq42 2022-12-09 10:39:14 -09:00
parent be0251eea8
commit 274d01a0e3

View File

@ -680,77 +680,40 @@ Return nil if DIR is not in a hugo project at all."
;; :custom ;(company-require-match nil)
;; (company-tooltip-align-annotations t)
;; :hook (prog-mode . company-mode))
;; (use-package company-lsp
;; :after (lsp company)
;; :config
;; (push 'company-lsp company-backends))
;; (use-package company-fuzzy
;; :diminish
;; :hook (company-mode . company-fuzzy-mode)
;; ;; :init
;; :custom
;; ;; (company-fuzzy-sorting-backend 'flx)
;; (company-fuzzy-prefix-on-top nil)
;; (company-fuzzy-history-backends '(company-yasnippet))
;; (company-fuzzy-trigger-symbols '("." "->" "<" "\"" "'" "@"))
;; (company-fuzzy-passthrough-backends '(company-capf)))
(use-package bash-completion
:after eshell
:config
(defun bash-completion-from-eshell ()
(interactive)
(let ((completion-at-point-functions '(bash-completion-eshell-capf)))
(completion-at-point)))
(defun bash-completion-eshell-capf ()
(bash-completion-dynamic-complete-nocomint
(save-excursion (eshell-bol) (point)) (point) t))
:general (general-define-key
:states 'insert
:maps 'eshell-mode-map
"TAB" 'bash-completion-from-eshell))
(use-package corfu
:if (display-graphic-p)
:custom
(completion-cycle-threshold 3)
(corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
(corfu-auto t) ;; Enable auto completion
(corfu-auto-delay 1.5)
(corfu-auto-prefix 2)
(corfu-separator ?-) ;; Orderless field separator
(corfu-quit-at-boundary 'separator) ;; Never quit at completion boundary
(corfu-quit-no-match 'separator) ;; Never quit, even if there is no match
(corfu-preview-current nil) ;; Disable current candidate preview
(corfu-preselect-first nil) ;; Disable candidate preselection
(corfu-on-exact-match nil) ;; Configure handling of exact matches
(corfu-scroll-margin 5) ;; Use scroll margin
(completion-cycle-threshold 0)
(tab-always-indent 'complete)
(corfu-auto t)
(corfu-quit-no-match t)
(corfu-count (- (window-total-height) 10))
;; (corfu-separator ";")
:init (global-corfu-mode)
;; (defun corfu-enable-always-in-minibuffer ()
;; "Enable Corfu in the minibuffer if Vertico/Mct are not active."
;; (unless (or (bound-and-true-p mct--active)
;; (bound-and-true-p vertico--input))
;; (setq-local corfu-auto nil) ;; Enable/disable auto completion
;; (corfu-mode 1)
;; (minibuffer-complete)))
;; (add-hook 'minibuffer-setup-hook #'corfu-enable-always-in-minibuffer 1)
;; (defun corfu-kill-in-minibuffer ()
;; "Kill corfu and minibuffer. To be bound to Esc."
;; (interactive)
;; (setq-local inhibit-debugger t)
;; (corfu-quit)
;; (exit-minibuffer)
;; )
(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))))
:config
(advice-add 'pcomplete-completions-at-point :around #'cape-wrap-silent)
(advice-add 'pcomplete-completions-at-point :around #'cape-wrap-purify)
:general
(general-define-key
:prefix-map 'corfu-map
"C-n" 'corfu-next
"C-p" 'corfu-previous
:states 'insert
:keymaps 'corfu-map
[tab] 'corfu-next
[backtab] 'corfu-previous
"RET" 'corfu-insert
"ESC" 'corfu-quit))
(use-package popon
:straight
(:type git
:repo "https://codeberg.org/akib/emacs-popon")
"ESC" 'corfu-quit
"C-h" 'corfu-info-documentation
"C-f" 'corfu-info-location))
:if (not (display-graphic-p)))
(use-package corfu-terminal
:straight