fix: remove cape-elisp-symbol from text-mode; corfu TAB tries yas-expand first
This commit is contained in:
30
config.el
30
config.el
@@ -589,14 +589,28 @@ and optional priority indicator [#A]."
|
||||
(use-package! cape
|
||||
:after corfu
|
||||
:config
|
||||
(defun martin/cape-capf-setup ()
|
||||
"Set up cape completion sources for prog-mode and text-mode."
|
||||
(add-to-list 'completion-at-point-functions #'cape-dabbrev 0) ; words from buffers
|
||||
(add-to-list 'completion-at-point-functions #'cape-file 0) ; file paths
|
||||
(add-to-list 'completion-at-point-functions #'cape-keyword 0) ; language keywords
|
||||
(add-to-list 'completion-at-point-functions #'cape-elisp-symbol 0))
|
||||
(add-hook 'prog-mode-hook #'martin/cape-capf-setup)
|
||||
(add-hook 'text-mode-hook #'martin/cape-capf-setup))
|
||||
(defun martin/cape-capf-setup-text ()
|
||||
"Cape sources for text modes (org, markdown, etc.) — no Elisp symbols."
|
||||
(add-to-list 'completion-at-point-functions #'cape-dabbrev 0)
|
||||
(add-to-list 'completion-at-point-functions #'cape-file 0))
|
||||
(defun martin/cape-capf-setup-prog ()
|
||||
"Cape sources for prog modes — includes Elisp symbols only in Elisp."
|
||||
(add-to-list 'completion-at-point-functions #'cape-dabbrev 0)
|
||||
(add-to-list 'completion-at-point-functions #'cape-file 0)
|
||||
(add-to-list 'completion-at-point-functions #'cape-keyword 0)
|
||||
(when (derived-mode-p 'emacs-lisp-mode)
|
||||
(add-to-list 'completion-at-point-functions #'cape-elisp-symbol 0)))
|
||||
(add-hook 'text-mode-hook #'martin/cape-capf-setup-text)
|
||||
(add-hook 'prog-mode-hook #'martin/cape-capf-setup-prog))
|
||||
|
||||
;; When corfu popup is active, TAB tries yasnippet first, then completes.
|
||||
;; Fixes: typing a snippet key (e.g. "adr") + TAB expands the snippet
|
||||
;; even when the corfu popup is showing unrelated candidates.
|
||||
(after! (corfu yasnippet)
|
||||
(define-key corfu-map [tab]
|
||||
(lambda () (interactive) (or (yas-expand) (corfu-complete))))
|
||||
(define-key corfu-map (kbd "TAB")
|
||||
(lambda () (interactive) (or (yas-expand) (corfu-complete)))))
|
||||
|
||||
;; Corfu popup in terminal — only needed for Emacs < 31 without child-frame support.
|
||||
;; Emacs 31 handles corfu natively even in terminal; loading corfu-terminal
|
||||
|
||||
Reference in New Issue
Block a user