dev: merging latest changes from pr7002
This commit is contained in:
commit
35e7bd2711
4 changed files with 92 additions and 99 deletions
|
@ -37,47 +37,18 @@ major mode regardless of size.")
|
|||
tab-always-indent (if (modulep! +tng) 'complete tab-always-indent))
|
||||
(add-to-list 'completion-category-overrides `(lsp-capf (styles ,@completion-styles)))
|
||||
|
||||
(map! :map corfu-mode-map
|
||||
:e "C-M-i" #'completion-at-point
|
||||
:i "C-SPC" #'completion-at-point
|
||||
:n "C-SPC" (cmd! (call-interactively #'evil-insert-state)
|
||||
(call-interactively #'completion-at-point))
|
||||
:v "C-SPC" (cmd! (call-interactively #'evil-change)
|
||||
(call-interactively #'completion-at-point)))
|
||||
(map! :unless (modulep! :editor evil)
|
||||
:map corfu-mode-map
|
||||
"C-M-i" #'completion-at-point)
|
||||
|
||||
(add-hook! corfu-mode
|
||||
(defun +corfu-mode-binds ()
|
||||
(defun +corfu-mode-unbinds ()
|
||||
;; In `corfu-mode', unbind C-SPC from `global-map', so Emacs keeps searching.
|
||||
(make-local-variable 'global-map)
|
||||
(unbind-key "C-SPC" 'global-map)))
|
||||
|
||||
(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)))
|
||||
(add-hook 'minibuffer-setup-hook #'+corfu-enable-in-minibuffer)
|
||||
;; 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)))))
|
||||
(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))
|
||||
|
@ -85,32 +56,9 @@ major mode regardless of size.")
|
|||
(when (modulep! +icons)
|
||||
(add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter))
|
||||
|
||||
(let ((cmds-del (cmds! (and (modulep! +tng)
|
||||
(> corfu--index -1)
|
||||
(eq corfu-preview-current 'insert))
|
||||
#'corfu-reset)))
|
||||
(map! :map corfu-map
|
||||
[return] #'corfu-insert
|
||||
"RET" #'corfu-insert
|
||||
(:when (modulep! +orderless)
|
||||
"<remap> <completion-at-point>" #'+corfu-smart-sep-toggle-escape)
|
||||
(:when (modulep! +tng)
|
||||
[tab] #'corfu-next
|
||||
[backtab] #'corfu-previous
|
||||
"TAB" #'corfu-next
|
||||
"S-TAB" #'corfu-previous
|
||||
[backspace] cmds-del
|
||||
"DEL" cmds-del)))
|
||||
|
||||
(when (modulep! +orderless)
|
||||
(after! orderless
|
||||
(setq orderless-component-separator #'orderless-escapable-split-on-space)))
|
||||
|
||||
(after! vertico
|
||||
(map! :map corfu-map
|
||||
"M-m" #'+corfu-move-to-minibuffer
|
||||
(:when (modulep! :editor evil)
|
||||
"M-J" #'+corfu-move-to-minibuffer))))
|
||||
(setq orderless-component-separator #'orderless-escapable-split-on-space))))
|
||||
|
||||
(use-package! cape
|
||||
:defer t
|
||||
|
@ -139,17 +87,6 @@ major mode regardless of size.")
|
|||
eshell-mode)
|
||||
(defun +corfu-add-cape-dabbrev-h ()
|
||||
(add-hook 'completion-at-point-functions #'cape-dabbrev 20 t)))))
|
||||
(when (modulep! +line)
|
||||
;; Set up `cape-line' options.
|
||||
(defun +cape-line-buffers ()
|
||||
(cl-loop for buf in (buffer-list)
|
||||
if (or (eq major-mode (buffer-local-value 'major-mode buf))
|
||||
(< (buffer-size buf) +corfu-buffer-scanning-size-limit))
|
||||
collect buf))
|
||||
(setq cape-line-buffer-function #'+cape-line-buffers)
|
||||
(add-hook! (text-mode comint-mode minibuffer-setup)
|
||||
(defun +corfu-add-cape-line-h ()
|
||||
(add-hook 'completion-at-point-functions #'cape-line 20 t))))
|
||||
;; Complete emojis :).
|
||||
(when (and (modulep! +emoji) (> emacs-major-version 28))
|
||||
(add-hook! (prog-mode conf-mode)
|
||||
|
@ -215,16 +152,4 @@ major mode regardless of size.")
|
|||
(use-package! corfu-popupinfo
|
||||
:hook ((corfu-mode . corfu-popupinfo-mode))
|
||||
:config
|
||||
(setq corfu-popupinfo-delay '(0.5 . 1.0))
|
||||
(map! :map corfu-map
|
||||
"C-<up>" #'corfu-popupinfo-scroll-down
|
||||
"C-<down>" #'corfu-popupinfo-scroll-up
|
||||
"C-S-p" #'corfu-popupinfo-scroll-down
|
||||
"C-S-n" #'corfu-popupinfo-scroll-up
|
||||
"C-h" #'corfu-popupinfo-toggle)
|
||||
(map! :when (modulep! :editor evil)
|
||||
:map corfu-popupinfo-map
|
||||
;; Reversed because popupinfo assumes opposite of what feels intuitive
|
||||
;; with evil.
|
||||
"C-S-k" #'corfu-popupinfo-scroll-down
|
||||
"C-S-j" #'corfu-popupinfo-scroll-up))
|
||||
(setq corfu-popupinfo-delay '(0.5 . 1.0)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue