fix(yasnippet): add yasnippet-capf first in CAPF list for corfu integration
This commit is contained in:
29
config.el
29
config.el
@@ -603,14 +603,14 @@ and optional priority indicator [#A]."
|
|||||||
(add-hook 'text-mode-hook #'martin/cape-capf-setup-text)
|
(add-hook 'text-mode-hook #'martin/cape-capf-setup-text)
|
||||||
(add-hook 'prog-mode-hook #'martin/cape-capf-setup-prog))
|
(add-hook 'prog-mode-hook #'martin/cape-capf-setup-prog))
|
||||||
|
|
||||||
;; When corfu popup is active, TAB tries yasnippet first, then completes.
|
;; Ensure yasnippet-capf is FIRST in completion-at-point-functions
|
||||||
;; Fixes: typing a snippet key (e.g. "adr") + TAB expands the snippet
|
;; so corfu shows snippets and TAB expands them (not inserts plain text).
|
||||||
;; even when the corfu popup is showing unrelated candidates.
|
;; Depth 0 + local=t puts it before cape backends. (GitHub issue #8183)
|
||||||
(after! (corfu yasnippet)
|
(after! (yasnippet corfu)
|
||||||
(define-key corfu-map [tab]
|
(dolist (hook '(org-mode-hook markdown-mode-hook text-mode-hook prog-mode-hook))
|
||||||
(lambda () (interactive) (or (yas-expand) (corfu-complete))))
|
(add-hook hook
|
||||||
(define-key corfu-map (kbd "TAB")
|
(lambda ()
|
||||||
(lambda () (interactive) (or (yas-expand) (corfu-complete)))))
|
(add-hook 'completion-at-point-functions #'yasnippet-capf 0 t)))))
|
||||||
|
|
||||||
;; Corfu popup in terminal — only needed for Emacs < 31 without child-frame support.
|
;; Corfu popup in terminal — only needed for Emacs < 31 without child-frame support.
|
||||||
;; Emacs 31 handles corfu natively even in terminal; loading corfu-terminal
|
;; Emacs 31 handles corfu natively even in terminal; loading corfu-terminal
|
||||||
@@ -1257,15 +1257,10 @@ Otherwise: runs interactive ement-connect, then opens rooms after sync."
|
|||||||
(push (expand-file-name "snippets/" org-directory) yas-snippet-dirs)
|
(push (expand-file-name "snippets/" org-directory) yas-snippet-dirs)
|
||||||
(yas-reload-all)
|
(yas-reload-all)
|
||||||
|
|
||||||
;; In Evil insert state, TAB first tries yas-expand, then falls back
|
;; TAB in Evil insert: with yasnippet-capf first in CAPF list,
|
||||||
;; to the default TAB behaviour (indent / org-cycle / corfu).
|
;; corfu shows snippets as expandable items — no manual TAB override needed.
|
||||||
;; This lets you type a snippet key (e.g. "adr") and press TAB to expand,
|
;; Standard indent-for-tab-command handles org-cycle / indent fallback.
|
||||||
;; without breaking org-mode cycling or completion.
|
)
|
||||||
(map! :i [tab]
|
|
||||||
(lambda ()
|
|
||||||
(interactive)
|
|
||||||
(or (yas-expand)
|
|
||||||
(indent-for-tab-command)))))
|
|
||||||
|
|
||||||
;;; ============================================================
|
;;; ============================================================
|
||||||
;;; NAVIGATION — link-hint, avy
|
;;; NAVIGATION — link-hint, avy
|
||||||
|
|||||||
Reference in New Issue
Block a user