dev: merge branch 'pr7002' into emenel
This commit is contained in:
commit
01878b82d2
3 changed files with 49 additions and 27 deletions
|
@ -3,10 +3,20 @@
|
||||||
(defvar +corfu-buffer-scanning-size-limit (* 1 1024 1024) ; 1 MB
|
(defvar +corfu-buffer-scanning-size-limit (* 1 1024 1024) ; 1 MB
|
||||||
"Size limit for a buffer to be scanned by `cape-dabbrev'.")
|
"Size limit for a buffer to be scanned by `cape-dabbrev'.")
|
||||||
|
|
||||||
|
(defvar +corfu-want-C-x-bindings t
|
||||||
|
"Whether `C-x' is a completion prefix in Evil insert state.")
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;;; Packages
|
;;; Packages
|
||||||
(use-package! corfu
|
(use-package! corfu
|
||||||
:hook (doom-first-input . global-corfu-mode)
|
:hook (doom-first-input . global-corfu-mode)
|
||||||
|
:init
|
||||||
|
(add-hook! 'minibuffer-setup-hook
|
||||||
|
(defun +corfu-enable-in-minibuffer ()
|
||||||
|
"Enable Corfu in the minibuffer if `completion-at-point' is bound."
|
||||||
|
(when (where-is-internal #'completion-at-point (list (current-local-map)))
|
||||||
|
(setq-local corfu-echo-delay nil)
|
||||||
|
(corfu-mode +1))))
|
||||||
:config
|
:config
|
||||||
(setq corfu-auto t
|
(setq corfu-auto t
|
||||||
corfu-auto-delay 0.1
|
corfu-auto-delay 0.1
|
||||||
|
@ -34,22 +44,34 @@
|
||||||
|
|
||||||
(add-to-list 'corfu-continue-commands #'+corfu-move-to-minibuffer)
|
(add-to-list 'corfu-continue-commands #'+corfu-move-to-minibuffer)
|
||||||
|
|
||||||
(add-hook! 'minibuffer-setup-hook
|
|
||||||
(defun +corfu-enable-in-minibuffer ()
|
|
||||||
"Enable Corfu in the minibuffer if `completion-at-point' is bound."
|
|
||||||
(when (where-is-internal #'completion-at-point (list (current-local-map)))
|
|
||||||
(setq-local corfu-echo-delay nil)
|
|
||||||
(corfu-mode +1))))
|
|
||||||
|
|
||||||
(after! evil
|
(add-hook 'evil-insert-state-exit-hook #'corfu-quit)
|
||||||
(add-hook 'evil-insert-state-exit-hook #'corfu-quit))
|
|
||||||
|
|
||||||
(when (modulep! +icons)
|
(when (modulep! +icons)
|
||||||
(add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter))
|
(add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter))
|
||||||
|
|
||||||
(when (modulep! +orderless)
|
(when (modulep! +orderless)
|
||||||
(after! orderless
|
(after! orderless
|
||||||
(setq orderless-component-separator #'orderless-escapable-split-on-space))))
|
(setq orderless-component-separator #'orderless-escapable-split-on-space)))
|
||||||
|
|
||||||
|
;; If you want to update the visual hints after completing minibuffer commands
|
||||||
|
;; with Corfu and exiting, you have to do it manually.
|
||||||
|
(defadvice! +corfu--insert-before-exit-minibuffer-a ()
|
||||||
|
:before #'exit-minibuffer
|
||||||
|
(when (or (and (frame-live-p corfu--frame)
|
||||||
|
(frame-visible-p corfu--frame))
|
||||||
|
(and (featurep 'corfu-terminal)
|
||||||
|
(popon-live-p corfu-terminal--popon)))
|
||||||
|
(when (member isearch-lazy-highlight-timer timer-idle-list)
|
||||||
|
(apply (timer--function isearch-lazy-highlight-timer)
|
||||||
|
(timer--args isearch-lazy-highlight-timer)))
|
||||||
|
(when (member (bound-and-true-p anzu--update-timer) timer-idle-list)
|
||||||
|
(apply (timer--function anzu--update-timer)
|
||||||
|
(timer--args anzu--update-timer)))
|
||||||
|
(when (member (bound-and-true-p evil--ex-search-update-timer)
|
||||||
|
timer-idle-list)
|
||||||
|
(apply (timer--function evil--ex-search-update-timer)
|
||||||
|
(timer--args evil--ex-search-update-timer))))))
|
||||||
|
|
||||||
(use-package! cape
|
(use-package! cape
|
||||||
:defer t
|
:defer t
|
||||||
|
@ -65,6 +87,10 @@
|
||||||
;; Set up `cape-dabbrev' options.
|
;; Set up `cape-dabbrev' options.
|
||||||
(defun +dabbrev-friend-buffer-p (other-buffer)
|
(defun +dabbrev-friend-buffer-p (other-buffer)
|
||||||
(< (buffer-size other-buffer) +corfu-buffer-scanning-size-limit))
|
(< (buffer-size other-buffer) +corfu-buffer-scanning-size-limit))
|
||||||
|
(add-hook! (prog-mode text-mode conf-mode comint-mode minibuffer-setup
|
||||||
|
eshell-mode)
|
||||||
|
(defun +corfu-add-cape-dabbrev-h ()
|
||||||
|
(add-hook 'completion-at-point-functions #'cape-dabbrev 20 t)))
|
||||||
(after! dabbrev
|
(after! dabbrev
|
||||||
(setq cape-dabbrev-check-other-buffers t
|
(setq cape-dabbrev-check-other-buffers t
|
||||||
dabbrev-friend-buffer-function #'+dabbrev-friend-buffer-p
|
dabbrev-friend-buffer-function #'+dabbrev-friend-buffer-p
|
||||||
|
@ -72,12 +98,7 @@
|
||||||
'("^ "
|
'("^ "
|
||||||
"\\(TAGS\\|tags\\|ETAGS\\|etags\\|GTAGS\\|GRTAGS\\|GPATH\\)\\(<[0-9]+>\\)?")
|
"\\(TAGS\\|tags\\|ETAGS\\|etags\\|GTAGS\\|GRTAGS\\|GPATH\\)\\(<[0-9]+>\\)?")
|
||||||
dabbrev-upcase-means-case-search t)
|
dabbrev-upcase-means-case-search t)
|
||||||
(add-to-list 'dabbrev-ignored-buffer-modes 'pdf-view-mode)
|
(add-to-list 'dabbrev-ignored-buffer-modes 'pdf-view-mode)))
|
||||||
|
|
||||||
(add-hook! (prog-mode text-mode conf-mode comint-mode minibuffer-setup
|
|
||||||
eshell-mode)
|
|
||||||
(defun +corfu-add-cape-dabbrev-h ()
|
|
||||||
(add-hook 'completion-at-point-functions #'cape-dabbrev 20 t)))))
|
|
||||||
;; Complete emojis :).
|
;; Complete emojis :).
|
||||||
(when (and (modulep! +emoji) (> emacs-major-version 28))
|
(when (and (modulep! +emoji) (> emacs-major-version 28))
|
||||||
(add-hook! (prog-mode conf-mode)
|
(add-hook! (prog-mode conf-mode)
|
||||||
|
|
|
@ -163,14 +163,15 @@
|
||||||
(:after corfu
|
(:after corfu
|
||||||
(:map corfu-mode-map
|
(:map corfu-mode-map
|
||||||
:e "C-M-i" #'completion-at-point
|
:e "C-M-i" #'completion-at-point
|
||||||
(:prefix "C-x"
|
(:when +corfu-want-C-x-bindings
|
||||||
:i "C-l" #'cape-line
|
(:prefix "C-x"
|
||||||
:i "C-k" #'cape-keyword
|
:i "C-l" #'cape-line
|
||||||
:i "C-f" #'cape-file
|
:i "C-k" #'cape-keyword
|
||||||
:i "s" #'cape-dict
|
:i "C-f" #'cape-file
|
||||||
:i "C-s" #'yasnippet-capf
|
:i "s" #'cape-dict
|
||||||
:i "C-n" #'cape-dabbrev
|
:i "C-s" #'yasnippet-capf
|
||||||
:i "C-p" #'cape-history)
|
:i "C-n" #'cape-dabbrev
|
||||||
|
:i "C-p" #'cape-history))
|
||||||
(:unless (modulep! :completion corfu +tng)
|
(:unless (modulep! :completion corfu +tng)
|
||||||
:i "C-SPC" #'completion-at-point
|
:i "C-SPC" #'completion-at-point
|
||||||
:n "C-SPC" (cmd! (call-interactively #'evil-insert-state)
|
:n "C-SPC" (cmd! (call-interactively #'evil-insert-state)
|
||||||
|
|
|
@ -469,10 +469,10 @@ Continues comments if executed from a commented line. Consults
|
||||||
(:when (modulep! :completion corfu +orderless)
|
(:when (modulep! :completion corfu +orderless)
|
||||||
[remap completion-at-point] #'+corfu-smart-sep-toggle-escape)
|
[remap completion-at-point] #'+corfu-smart-sep-toggle-escape)
|
||||||
(:when (modulep! :completion corfu +tng)
|
(:when (modulep! :completion corfu +tng)
|
||||||
[tab] #'corfu-next
|
:gi [tab] #'corfu-next
|
||||||
"TAB" #'corfu-next
|
:gi "TAB" #'corfu-next
|
||||||
[backtab] #'corfu-previous
|
:gi [backtab] #'corfu-previous
|
||||||
"S-TAB" #'corfu-previous))
|
:gi "S-TAB" #'corfu-previous))
|
||||||
(:after corfu-popupinfo
|
(:after corfu-popupinfo
|
||||||
:map corfu-popupinfo-map
|
:map corfu-popupinfo-map
|
||||||
"C-<up>" #'corfu-popupinfo-scroll-down
|
"C-<up>" #'corfu-popupinfo-scroll-down
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue