tweak(corfu): place extra CAPFs behind flags
This commit is contained in:
parent
747ecebd24
commit
14ea4b0b89
2 changed files with 46 additions and 33 deletions
|
@ -20,12 +20,20 @@ highly non-native, but has some extra features and more maturity.
|
||||||
- +icons ::
|
- +icons ::
|
||||||
Display icons beside completion suggestions.
|
Display icons beside completion suggestions.
|
||||||
- +tng ::
|
- +tng ::
|
||||||
Invoke completion on [[kbd:][TAB]]. When corfu is active, [[kbd:][TAB]] and [[kbd:][S-TAB]] will navigate
|
Invoke completion on [[kbd:][TAB]]. When corfu is active, [[kbd:][TAB]] and
|
||||||
the completion candidates. Arrow keys and evil-style movement are still
|
[[kbd:][S-TAB]] will navigate the completion candidates. Arrow keys and
|
||||||
supported.
|
evil-style movement are still supported.
|
||||||
- +orderless ::
|
- +orderless ::
|
||||||
Pull in [[doom-package:orderless]] if necessary and apply multi-component
|
Pull in [[doom-package:orderless]] if necessary and apply multi-component
|
||||||
completion (still needed if [[doom-module::completion vertico]] is active).
|
completion (still needed if [[doom-module::completion vertico]] is active).
|
||||||
|
- +dabbrev ::
|
||||||
|
Enable and configure [[doom-package:dabbrev]] as a nigh on everywhere CAPF
|
||||||
|
fallback.
|
||||||
|
- +dict ::
|
||||||
|
Enable and configure dictionary completion for text modes and related regions
|
||||||
|
in programming modes.
|
||||||
|
- +emoji ::
|
||||||
|
Enable and configure emoji completion via the emoji input method.
|
||||||
|
|
||||||
** Packages
|
** Packages
|
||||||
- [[doom-package:corfu]]
|
- [[doom-package:corfu]]
|
||||||
|
|
|
@ -178,35 +178,39 @@ This variable needs to be set at the top-level before any `after!' blocks.")
|
||||||
(use-package! cape
|
(use-package! cape
|
||||||
:defer t
|
:defer t
|
||||||
:init
|
:init
|
||||||
;; Set up `cape-dabbrev' and `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) +cape-buffer-scanning-size-limit))
|
|
||||||
collect buf))
|
|
||||||
(defun +dabbrev-friend-buffer-p (other-buffer)
|
|
||||||
(< (buffer-size other-buffer) +cape-buffer-scanning-size-limit))
|
|
||||||
(setq cape-dabbrev-check-other-buffers t
|
|
||||||
cape-line-buffer-function #'+cape-line-buffers
|
|
||||||
dabbrev-friend-buffer-function #'+dabbrev-friend-buffer-p
|
|
||||||
dabbrev-ignored-buffer-regexps
|
|
||||||
'("\\.\\(?:pdf\\|jpe?g\\|png\\|svg\\|eps\\)\\'"
|
|
||||||
"^ "
|
|
||||||
"\\(TAGS\\|tags\\|ETAGS\\|etags\\|GTAGS\\|GRTAGS\\|GPATH\\)\\(<[0-9]+>\\)?")
|
|
||||||
dabbrev-upcase-means-case-search t)
|
|
||||||
|
|
||||||
(add-hook! prog-mode
|
(add-hook! prog-mode
|
||||||
(add-hook 'completion-at-point-functions #'cape-file -10 t))
|
(add-hook 'completion-at-point-functions #'cape-file -10 t))
|
||||||
(add-hook! (org-mode markdown-mode)
|
(add-hook! (org-mode markdown-mode)
|
||||||
(add-hook 'completion-at-point-functions #'cape-elisp-block 0 t))
|
(add-hook 'completion-at-point-functions #'cape-elisp-block 0 t))
|
||||||
|
|
||||||
;; Enable Dabbrev completion basically everywhere as a fallback.
|
;; Enable Dabbrev completion basically everywhere as a fallback.
|
||||||
(add-hook! (prog-mode text-mode conf-mode comint-mode minibuffer-setup
|
(when (modulep! +dabbrev)
|
||||||
eshell-mode)
|
;; Set up `cape-dabbrev' options.
|
||||||
(add-hook 'completion-at-point-functions #'cape-dabbrev 20 t))
|
(defun +dabbrev-friend-buffer-p (other-buffer)
|
||||||
|
(< (buffer-size other-buffer) +cape-buffer-scanning-size-limit))
|
||||||
|
(setq cape-dabbrev-check-other-buffers t
|
||||||
|
dabbrev-friend-buffer-function #'+dabbrev-friend-buffer-p
|
||||||
|
dabbrev-ignored-buffer-regexps
|
||||||
|
'("\\.\\(?:pdf\\|jpe?g\\|png\\|svg\\|eps\\)\\'"
|
||||||
|
"^ "
|
||||||
|
"\\(TAGS\\|tags\\|ETAGS\\|etags\\|GTAGS\\|GRTAGS\\|GPATH\\)\\(<[0-9]+>\\)?")
|
||||||
|
dabbrev-upcase-means-case-search t)
|
||||||
|
(add-hook! (prog-mode text-mode conf-mode comint-mode minibuffer-setup
|
||||||
|
eshell-mode)
|
||||||
|
(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) +cape-buffer-scanning-size-limit))
|
||||||
|
collect buf))
|
||||||
|
(setq cape-line-buffer-function #'+cape-line-buffers)
|
||||||
|
(add-hook! (text-mode comint-mode minibuffer-setup)
|
||||||
|
(add-hook 'completion-at-point-functions #'cape-line 20 t)))
|
||||||
|
|
||||||
;; Complete emojis :).
|
;; Complete emojis :).
|
||||||
(when (> emacs-major-version 28)
|
(when (and (modulep! +emoji) (> emacs-major-version 28))
|
||||||
(add-hook! (prog-mode conf-mode)
|
(add-hook! (prog-mode conf-mode)
|
||||||
(add-hook 'completion-at-point-functions
|
(add-hook 'completion-at-point-functions
|
||||||
(cape-capf-inside-faces
|
(cape-capf-inside-faces
|
||||||
|
@ -220,15 +224,16 @@ This variable needs to be set at the top-level before any `after!' blocks.")
|
||||||
(cape-capf-prefix-length #'cape-emoji 1) 10 t)))
|
(cape-capf-prefix-length #'cape-emoji 1) 10 t)))
|
||||||
|
|
||||||
;; Enable dictionary-based autocompletion.
|
;; Enable dictionary-based autocompletion.
|
||||||
(add-hook! text-mode
|
(when (modulep! +dict)
|
||||||
(add-hook 'completion-at-point-functions #'cape-dict 40 t))
|
(add-hook! text-mode
|
||||||
(add-hook! (prog-mode conf-mode)
|
(add-hook 'completion-at-point-functions #'cape-dict 40 t))
|
||||||
(add-hook 'completion-at-point-functions
|
(add-hook! (prog-mode conf-mode)
|
||||||
(cape-capf-inside-faces
|
(add-hook 'completion-at-point-functions
|
||||||
;; Only call inside comments and docstrings.
|
(cape-capf-inside-faces
|
||||||
#'cape-dict 'tree-sitter-hl-face:doc 'font-lock-doc-face
|
;; Only call inside comments and docstrings.
|
||||||
'font-lock-comment-face 'tree-sitter-hl-face:comment)
|
#'cape-dict 'tree-sitter-hl-face:doc 'font-lock-doc-face
|
||||||
40 t))
|
'font-lock-comment-face 'tree-sitter-hl-face:comment)
|
||||||
|
40 t)))
|
||||||
|
|
||||||
;; Make these capfs composable.
|
;; Make these capfs composable.
|
||||||
(advice-add #'comint-completion-at-point :around #'cape-wrap-nonexclusive)
|
(advice-add #'comint-completion-at-point :around #'cape-wrap-nonexclusive)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue