dev: updating from latest
This commit is contained in:
commit
eaa9d0e188
3 changed files with 69 additions and 27 deletions
|
@ -49,3 +49,18 @@
|
||||||
;; Without this corfu quits immediately.
|
;; Without this corfu quits immediately.
|
||||||
(setq this-command #'corfu-insert-separator)
|
(setq this-command #'corfu-insert-separator)
|
||||||
(call-interactively #'corfu-insert-separator))))
|
(call-interactively #'corfu-insert-separator))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +corfu-in-doc-or-comment-p (_sym)
|
||||||
|
"Return non-nil if point is in a docstring or comment."
|
||||||
|
(or (nth 4 (syntax-ppss))
|
||||||
|
(when-let ((faces '(font-lock-comment-face
|
||||||
|
font-lock-doc-face
|
||||||
|
tree-sitter-hl-face:doc
|
||||||
|
tree-sitter-hl-face:comment))
|
||||||
|
(fs (get-text-property (point) 'face)))
|
||||||
|
(if (listp fs)
|
||||||
|
(cl-loop for f in fs
|
||||||
|
if (memq f faces)
|
||||||
|
return t)
|
||||||
|
(memq fs faces)))))
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
(defvar +corfu-want-C-x-bindings t
|
(defvar +corfu-want-C-x-bindings t
|
||||||
"Whether `C-x' is a completion prefix in Evil insert state.")
|
"Whether `C-x' is a completion prefix in Evil insert state.")
|
||||||
|
|
||||||
|
(defvar +corfu-want-minibuffer-completion t
|
||||||
|
"Whether to enable Corfu in the minibuffer.
|
||||||
|
Setting this to `aggressive' will enable Corfu in more commands which
|
||||||
|
use the minibuffer such as `query-replace'.")
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;;; Packages
|
;;; Packages
|
||||||
(use-package! corfu
|
(use-package! corfu
|
||||||
|
@ -13,10 +18,25 @@
|
||||||
:init
|
:init
|
||||||
(add-hook! 'minibuffer-setup-hook
|
(add-hook! 'minibuffer-setup-hook
|
||||||
(defun +corfu-enable-in-minibuffer ()
|
(defun +corfu-enable-in-minibuffer ()
|
||||||
"Enable Corfu in the minibuffer if `completion-at-point' is bound."
|
"Enable Corfu in the minibuffer."
|
||||||
(when (where-is-internal #'completion-at-point (list (current-local-map)))
|
(when (pcase +corfu-want-minibuffer-completion
|
||||||
|
('aggressive
|
||||||
|
(not (or (bound-and-true-p mct--active)
|
||||||
|
(bound-and-true-p vertico--input)
|
||||||
|
(eq (current-local-map) read-passwd-map)
|
||||||
|
(and (featurep 'helm-core) (helm--alive-p))
|
||||||
|
(and (featurep 'ido) (ido-active))
|
||||||
|
(where-is-internal 'minibuffer-complete
|
||||||
|
(list (current-local-map)))
|
||||||
|
(memq #'ivy--queue-exhibit post-command-hook))))
|
||||||
|
('nil nil)
|
||||||
|
(_ (where-is-internal #'completion-at-point
|
||||||
|
(list (current-local-map)))))
|
||||||
(setq-local corfu-echo-delay nil)
|
(setq-local corfu-echo-delay nil)
|
||||||
(corfu-mode +1))))
|
(corfu-mode +1))))
|
||||||
|
(when (modulep! +orderless)
|
||||||
|
(after! orderless
|
||||||
|
(setq orderless-component-separator #'orderless-escapable-split-on-space)))
|
||||||
:config
|
:config
|
||||||
(setq corfu-auto t
|
(setq corfu-auto t
|
||||||
corfu-auto-delay 0.1
|
corfu-auto-delay 0.1
|
||||||
|
@ -41,6 +61,7 @@
|
||||||
;; However, it should otherwise behave like normal, whatever normal was.
|
;; However, it should otherwise behave like normal, whatever normal was.
|
||||||
tab-always-indent (if (modulep! +tng) 'complete tab-always-indent))
|
tab-always-indent (if (modulep! +tng) 'complete tab-always-indent))
|
||||||
(add-to-list 'completion-category-overrides `(lsp-capf (styles ,@completion-styles)))
|
(add-to-list 'completion-category-overrides `(lsp-capf (styles ,@completion-styles)))
|
||||||
|
(add-to-list 'corfu-auto-commands #'lispy-colon)
|
||||||
|
|
||||||
(add-to-list 'corfu-continue-commands #'+corfu-move-to-minibuffer)
|
(add-to-list 'corfu-continue-commands #'+corfu-move-to-minibuffer)
|
||||||
|
|
||||||
|
@ -50,10 +71,6 @@
|
||||||
(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)
|
|
||||||
(after! orderless
|
|
||||||
(setq orderless-component-separator #'orderless-escapable-split-on-space)))
|
|
||||||
|
|
||||||
;; If you want to update the visual hints after completing minibuffer commands
|
;; If you want to update the visual hints after completing minibuffer commands
|
||||||
;; with Corfu and exiting, you have to do it manually.
|
;; with Corfu and exiting, you have to do it manually.
|
||||||
(defadvice! +corfu--insert-before-exit-minibuffer-a ()
|
(defadvice! +corfu--insert-before-exit-minibuffer-a ()
|
||||||
|
@ -104,11 +121,8 @@
|
||||||
(add-hook! (prog-mode conf-mode)
|
(add-hook! (prog-mode conf-mode)
|
||||||
(defun +corfu-add-cape-emoji-h ()
|
(defun +corfu-add-cape-emoji-h ()
|
||||||
(add-hook 'completion-at-point-functions
|
(add-hook 'completion-at-point-functions
|
||||||
(cape-capf-inside-faces
|
(cape-capf-predicate (cape-capf-prefix-length #'cape-emoji 1)
|
||||||
(cape-capf-prefix-length #'cape-emoji 1)
|
#'+corfu-in-doc-or-comment-p)
|
||||||
;; Only call inside comments and docstrings.
|
|
||||||
'tree-sitter-hl-face:doc 'font-lock-doc-face
|
|
||||||
'font-lock-comment-face 'tree-sitter-hl-face:comment)
|
|
||||||
10 t)))
|
10 t)))
|
||||||
(add-hook! text-mode
|
(add-hook! text-mode
|
||||||
(defun +corfu-add-cape-emoji-text-h ()
|
(defun +corfu-add-cape-emoji-text-h ()
|
||||||
|
@ -119,10 +133,7 @@
|
||||||
(add-hook! (prog-mode conf-mode)
|
(add-hook! (prog-mode conf-mode)
|
||||||
(defun +corfu-add-cape-dict-h ()
|
(defun +corfu-add-cape-dict-h ()
|
||||||
(add-hook 'completion-at-point-functions
|
(add-hook 'completion-at-point-functions
|
||||||
(cape-capf-inside-faces
|
(cape-capf-predicate #'+corfu-in-doc-or-comment-p #'cape-dict)
|
||||||
;; Only call inside comments and docstrings.
|
|
||||||
#'cape-dict 'tree-sitter-hl-face:doc 'font-lock-doc-face
|
|
||||||
'font-lock-comment-face 'tree-sitter-hl-face:comment)
|
|
||||||
40 t)))
|
40 t)))
|
||||||
(add-hook! text-mode
|
(add-hook! text-mode
|
||||||
(defun +corfu-add-cape-dict-text-h ()
|
(defun +corfu-add-cape-dict-text-h ()
|
||||||
|
|
|
@ -461,8 +461,6 @@ Continues comments if executed from a commented line. Consults
|
||||||
(map! :when (modulep! :completion corfu)
|
(map! :when (modulep! :completion corfu)
|
||||||
:after corfu
|
:after corfu
|
||||||
(:map corfu-map
|
(:map corfu-map
|
||||||
[return] #'corfu-insert
|
|
||||||
"RET" #'corfu-insert
|
|
||||||
"C-S-s" #'+corfu-move-to-minibuffer
|
"C-S-s" #'+corfu-move-to-minibuffer
|
||||||
"C-p" #'corfu-previous
|
"C-p" #'corfu-previous
|
||||||
"C-n" #'corfu-next
|
"C-n" #'corfu-next
|
||||||
|
@ -481,19 +479,37 @@ Continues comments if executed from a commented line. Consults
|
||||||
"C-S-n" #'corfu-popupinfo-scroll-up
|
"C-S-n" #'corfu-popupinfo-scroll-up
|
||||||
"C-S-u" (cmd! (funcall-interactively #'corfu-popupinfo-scroll-down corfu-popupinfo-min-height))
|
"C-S-u" (cmd! (funcall-interactively #'corfu-popupinfo-scroll-down corfu-popupinfo-min-height))
|
||||||
"C-S-d" (cmd! (funcall-interactively #'corfu-popupinfo-scroll-up corfu-popupinfo-min-height)))
|
"C-S-d" (cmd! (funcall-interactively #'corfu-popupinfo-scroll-up corfu-popupinfo-min-height)))
|
||||||
|
(:when (not (modulep! :completion corfu +tng))
|
||||||
(:map corfu-map
|
(:map corfu-map
|
||||||
"C-<return>" '(menu-item "Conclude the minibuffer" exit-minibuffer
|
"C-<return>" `(menu-item "Conclude the minibuffer" exit-minibuffer
|
||||||
:enable (minibufferp nil t))
|
:filter ,(lambda (cmd) (when (minibufferp nil t) cmd)))
|
||||||
"S-<return>" '(menu-item "Insert completion and conclude" +corfu-complete-and-exit-minibuffer
|
"S-<return>" `(menu-item "Insert completion and conclude"
|
||||||
:enable (minibufferp nil t))))
|
+corfu-complete-and-exit-minibuffer
|
||||||
|
:filter ,(lambda (cmd) (when (minibufferp nil t) cmd))))))
|
||||||
(when-let ((cmds-del (and (modulep! :completion corfu +tng)
|
(when-let ((cmds-del (and (modulep! :completion corfu +tng)
|
||||||
'(menu-item "Reset completion" corfu-reset
|
`(menu-item "Reset completion" corfu-reset
|
||||||
:enable (and (> corfu--index -1)
|
:filter ,(lambda (cmd)
|
||||||
(eq corfu-preview-current 'insert))))))
|
(when (and (>= corfu--index 0)
|
||||||
(map! :after corfu
|
(eq corfu-preview-current 'insert))
|
||||||
|
cmd)))))
|
||||||
|
(cmds-ret `(menu-item "Insert completion" corfu-insert
|
||||||
|
:filter ,(lambda (cmd)
|
||||||
|
(cond ((eq corfu--index -1)
|
||||||
|
(corfu-quit))
|
||||||
|
((and (modulep! :completion corfu +tng)
|
||||||
|
(eq corfu-preview-current 'insert)
|
||||||
|
(minibufferp nil t))
|
||||||
|
(corfu-insert)
|
||||||
|
nil)
|
||||||
|
(t
|
||||||
|
cmd))))))
|
||||||
|
(map! :when (modulep! :completion corfu)
|
||||||
|
:after corfu
|
||||||
:map corfu-map
|
:map corfu-map
|
||||||
[backspace] cmds-del
|
[backspace] cmds-del
|
||||||
"DEL" cmds-del))
|
"DEL" cmds-del
|
||||||
|
:ig [return] cmds-ret
|
||||||
|
:ig "RET" cmds-ret))
|
||||||
|
|
||||||
;; Smarter C-a/C-e for both Emacs and Evil. C-a will jump to indentation.
|
;; Smarter C-a/C-e for both Emacs and Evil. C-a will jump to indentation.
|
||||||
;; Pressing it again will send you to the true bol. Same goes for C-e, except
|
;; Pressing it again will send you to the true bol. Same goes for C-e, except
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue