dev: merge branch 'master' into emenel
This commit is contained in:
commit
831e2c7402
16 changed files with 267 additions and 215 deletions
|
@ -74,7 +74,6 @@ composed to suit the user. The following keybindings are generally available:
|
|||
| [[kbd:][C-S-n]] | Go to next doc line |
|
||||
| [[kbd:][C-S-p]] | Go to previous doc line |
|
||||
| [[kbd:][C-S-s]] | Export to minibuffer |
|
||||
| [[kbd:][DEL]] | Reset completion DWIM |
|
||||
| [[kbd:][TAB]] | (when not completing) Indent or complete |
|
||||
| [[kbd:][C-SPC]] | (when not completing) Complete |
|
||||
| [[kbd:][C-u]] | (evil) Go to next candidate page |
|
||||
|
@ -82,19 +81,16 @@ composed to suit the user. The following keybindings are generally available:
|
|||
| [[kbd:][C-h]] | (evil) Toggle documentation (if available) |
|
||||
| [[kbd:][M-t]] | (emacs) (when not completing) Complete |
|
||||
|
||||
Bindings in the following sections are additive, and get enabled by including
|
||||
the corresponding ~config.el~ snippets or via flags. Additionally, for users of
|
||||
evil, [[kdb:][C-SPC]] is smart regarding your state. In normal-like states, enter insert
|
||||
then start corfu; in visual-like states, perform [[help:evil-change][evil-change]] (which leaves you
|
||||
in insert state) then start corfu; in insert-like states, start corfu
|
||||
immediatelly.
|
||||
Bindings in the following sections are additive, and unless otherwise noted, are
|
||||
enabled by default with configurable behavior. Additionally, for users of evil,
|
||||
[[kdb:][C-SPC]] is smart regarding your state. In normal-like states, enter insert then
|
||||
start corfu; in visual-like states, perform [[help:evil-change][evil-change]] (which leaves you in
|
||||
insert state) then start corfu; in insert-like states, start corfu immediatelly.
|
||||
|
||||
** Commit preview on type
|
||||
When the completion popup is visible, by default the current candidate is
|
||||
previewed into the buffer, and further input commits that candidate as previewed
|
||||
(note it does not perform candidate exit actions, such as expanding snippets).
|
||||
If neither ~+on-ret~ or ~+on-ret-pt~ are enabled, this becomes the only default
|
||||
way to commit a candidate ([[kbd:][RET]] is unbound in that case).
|
||||
|
||||
The feature is in line with other common editors, but if you prefer the preview
|
||||
to be only visual or for there to be no preview, configure
|
||||
|
@ -166,10 +162,10 @@ you accidentaly press more than needed.
|
|||
| [[kbd:][SPC]] | (when completing with separators) Self-insert |
|
||||
|
||||
** Exporting to the minibuffer
|
||||
The entries shown in the completion popup can be exported to another
|
||||
~completion-in-region~ minibuffer, giving access to all the manipulations those
|
||||
suites allow. Using Vertico for instance, one could use this to export with
|
||||
[[doom-package:embark]] via [[kbd:][C-c C-l]] and get a buffer with all candidates.
|
||||
The entries shown in the completion popup can be exported to a ~completing-read~
|
||||
minibuffer, giving access to all the manipulations that suite allows. Using
|
||||
Vertico for instance, one could use this to export with [[doom-package:embark]] via
|
||||
[[kbd:][C-c C-l]] and get a buffer with all candidates.
|
||||
|
||||
* Configuration
|
||||
A few variables may be set to change behavior of this module:
|
||||
|
@ -196,16 +192,16 @@ A few variables may be set to change behavior of this module:
|
|||
prompt.
|
||||
- [[var:corfu-preview-current]] ::
|
||||
Configures current candidate preview.
|
||||
- [[var:+corfu-buffer-scanning-size-limit]] ::
|
||||
Sets the maximum buffer size to be scanned by ~cape-dabbrev~. Defaults to 1
|
||||
MB. Set this if you are having performance problems using the CAPF.
|
||||
- [[var:+corfu-want-minibuffer-completion]] ::
|
||||
Enables Corfu in the minibuffer, where it may be obtrusive. May also be set
|
||||
to ~aggresive~ to enable even in some places without ~completion-at-point~.
|
||||
- [[var:+corfu-want-ret-to-confirm]] ::
|
||||
Enables commiting with [[RET]] when the popup is visible. Default is ~t~, may be set to
|
||||
~'minibuffer~ if you want to commit both the completion and the minibuffer when
|
||||
active. When ~nil~, it is always passed-through.
|
||||
- [[var:+corfu-buffer-scanning-size-limit]] ::
|
||||
Sets the maximum buffer size to be scanned by ~cape-dabbrev~. Defaults to 1 MB.
|
||||
Set this if you are having performance problems using the CAPF.
|
||||
- [[var:+corfu-want-minibuffer-completion]] ::
|
||||
Whether to enable Corfu in the minibuffer. See its documentation for
|
||||
additional tweaks.
|
||||
|
||||
** Adding CAPFs to a mode
|
||||
To add other CAPFs on a mode-per-mode basis, put either of the following in your
|
||||
|
@ -222,9 +218,7 @@ see ~add-hook!~'s documentation for additional ways to call it. ~add-hook~ only
|
|||
accepts the quoted arguments form above.
|
||||
|
||||
** Adding CAPFs to a key
|
||||
You may want to add other CAPFs to keys, so as to not pollute auto completion
|
||||
and use only when demanded. To do so, adapt the snippet below into your
|
||||
~config.el~:
|
||||
To add other CAPFs to keys, adapt the snippet below into your ~config.el~:
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(map! :map some-mode-map
|
||||
|
|
|
@ -14,17 +14,16 @@
|
|||
((and (modulep! :completion ivy)
|
||||
(fboundp #'ivy-completion-in-region))
|
||||
(ivy-completion-in-region (marker-position beg) (marker-position end) table pred))
|
||||
;; Helm is special and wants to _wrap_ `completion--in-region'
|
||||
;; instead of replacing it in `completion-in-region-function'.
|
||||
((and (modulep! :completion helm)
|
||||
(fboundp #'helm--completion-in-region)
|
||||
(advice-member-p #'helm--completion-in-region #'completion--in-region))
|
||||
;; Important: `completion-in-region-function' is set to corfu at
|
||||
;; this moment, so `completion-in-region' (single -) doesn't work.
|
||||
;; Important: `completion-in-region-function' is set to corfu at
|
||||
;; this moment, so `completion-in-region' (single -) doesn't work
|
||||
;; below.
|
||||
((modulep! :completion helm)
|
||||
;; Helm is special and wants to _wrap_ `completion--in-region'
|
||||
;; instead of replacing it in `completion-in-region-function'.
|
||||
;; But because the advice is too unreliable we "fake" the wrapping.
|
||||
(helm--completion-in-region #'completion--in-region beg end table pred))
|
||||
((modulep! :completion ido)
|
||||
(completion--in-region beg end table pred))
|
||||
;; Ido doesn't implement `completion-in-region', and its
|
||||
;; `completing-read' only accepts a plain list of strings as table,
|
||||
;; so there's not much we can do with it.
|
||||
(t (error "No minibuffer completion UI available for moving to!")))))))
|
||||
|
||||
;;;###autoload
|
||||
|
@ -37,5 +36,4 @@
|
|||
((char-equal (char-before) corfu-separator)
|
||||
(save-excursion (backward-char 1)
|
||||
(insert-char ?\\)))
|
||||
(t
|
||||
(call-interactively #'corfu-insert-separator))))
|
||||
(t (call-interactively #'corfu-insert-separator))))
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
;;; completion/corfu/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defvar +corfu-buffer-scanning-size-limit (* 1 1024 1024) ; 1 MB
|
||||
"Size limit for a buffer to be scanned by `cape-dabbrev'.")
|
||||
|
||||
(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'.")
|
||||
|
||||
(defvar +corfu-want-ret-to-confirm t
|
||||
"Configure how the user expects RET to behave.
|
||||
Possible values are:
|
||||
|
@ -16,6 +8,14 @@ Possible values are:
|
|||
and immediatelly exit if in the minibuffer;
|
||||
- nil: Pass-through without inserting.")
|
||||
|
||||
(defvar +corfu-buffer-scanning-size-limit (* 1 1024 1024) ; 1 MB
|
||||
"Size limit for a buffer to be scanned by `cape-dabbrev'.")
|
||||
|
||||
(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
|
||||
(use-package! corfu
|
||||
|
@ -39,9 +39,6 @@ Possible values are:
|
|||
(list (current-local-map)))))
|
||||
(setq-local corfu-echo-delay nil)
|
||||
(corfu-mode +1))))
|
||||
(when (modulep! +orderless)
|
||||
(after! orderless
|
||||
(setq orderless-component-separator #'orderless-escapable-split-on-space)))
|
||||
:config
|
||||
(setq corfu-auto t
|
||||
corfu-auto-delay 0.1
|
||||
|
@ -54,11 +51,9 @@ Possible values are:
|
|||
vterm-mode)
|
||||
t)
|
||||
corfu-cycle t
|
||||
corfu-separator (when (modulep! +orderless) ?\s)
|
||||
corfu-preselect 'prompt
|
||||
corfu-count 16
|
||||
corfu-max-width 120
|
||||
corfu-preview-current 'insert
|
||||
corfu-on-exact-match nil
|
||||
corfu-quit-at-boundary (if (modulep! +orderless) 'separator t)
|
||||
corfu-quit-no-match (if (modulep! +orderless) 'separator t)
|
||||
|
@ -69,9 +64,6 @@ Possible values are:
|
|||
(add-to-list 'corfu-continue-commands #'+corfu-smart-sep-toggle-escape)
|
||||
(add-hook 'evil-insert-state-exit-hook #'corfu-quit)
|
||||
|
||||
(when (modulep! +icons)
|
||||
(add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter))
|
||||
|
||||
;; 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 ()
|
||||
|
@ -89,7 +81,21 @@ Possible values are:
|
|||
(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))))))
|
||||
(timer--args evil--ex-search-update-timer)))))
|
||||
|
||||
;; HACK: If your dictionaries aren't set up in text-mode buffers, ispell will
|
||||
;; continuously pester you about errors. This ensures it only happens once
|
||||
;; per session.
|
||||
(defadvice! +corfu--auto-disable-ispell-capf-a (fn &rest args)
|
||||
"If ispell isn't properly set up, only complain once per session."
|
||||
:around #'ispell-completion-at-point
|
||||
(condition-case-unless-debug e
|
||||
(apply fn args)
|
||||
('error
|
||||
(message "Error: %s" (error-message-string e))
|
||||
(message "Auto-disabling `text-mode-ispell-word-completion'")
|
||||
(setq text-mode-ispell-word-completion nil)
|
||||
(remove-hook 'completion-at-point-functions #'ispell-completion-at-point t)))))
|
||||
|
||||
(use-package! cape
|
||||
:defer t
|
||||
|
@ -102,6 +108,7 @@ Possible values are:
|
|||
(add-hook 'completion-at-point-functions #'cape-elisp-block 0 t)))
|
||||
;; Enable Dabbrev completion basically everywhere as a fallback.
|
||||
(when (modulep! +dabbrev)
|
||||
(setq cape-dabbrev-check-other-buffers t)
|
||||
;; Set up `cape-dabbrev' options.
|
||||
(defun +dabbrev-friend-buffer-p (other-buffer)
|
||||
(< (buffer-size other-buffer) +corfu-buffer-scanning-size-limit))
|
||||
|
@ -110,8 +117,7 @@ Possible values are:
|
|||
(defun +corfu-add-cape-dabbrev-h ()
|
||||
(add-hook 'completion-at-point-functions #'cape-dabbrev 20 t)))
|
||||
(after! dabbrev
|
||||
(setq cape-dabbrev-check-other-buffers t
|
||||
dabbrev-friend-buffer-function #'+dabbrev-friend-buffer-p
|
||||
(setq dabbrev-friend-buffer-function #'+dabbrev-friend-buffer-p
|
||||
dabbrev-ignored-buffer-regexps
|
||||
'("^ "
|
||||
"\\(TAGS\\|tags\\|ETAGS\\|etags\\|GTAGS\\|GRTAGS\\|GPATH\\)\\(<[0-9]+>\\)?")
|
||||
|
@ -119,16 +125,16 @@ Possible values are:
|
|||
(add-to-list 'dabbrev-ignored-buffer-modes 'pdf-view-mode)))
|
||||
|
||||
;; Make these capfs composable.
|
||||
(advice-add #'lsp-completion-at-point :around #'cape-wrap-noninterruptible)
|
||||
(advice-add #'lsp-completion-at-point :around #'cape-wrap-nonexclusive)
|
||||
(advice-add #'comint-completion-at-point :around #'cape-wrap-nonexclusive)
|
||||
(advice-add #'eglot-completion-at-point :around #'cape-wrap-nonexclusive)
|
||||
(advice-add #'lsp-completion-at-point :around #'cape-wrap-nonexclusive)
|
||||
(advice-add #'pcomplete-completions-at-point :around #'cape-wrap-nonexclusive)
|
||||
;; From the `cape' readme. Without this, Eshell autocompletion is broken on
|
||||
;; Emacs28.
|
||||
(when (< emacs-major-version 29)
|
||||
(advice-add 'pcomplete-completions-at-point :around #'cape-wrap-silent)
|
||||
(advice-add 'pcomplete-completions-at-point :around #'cape-wrap-purify))
|
||||
(advice-add #'lsp-completion-at-point :around #'cape-wrap-noninterruptible))
|
||||
(advice-add 'pcomplete-completions-at-point :around #'cape-wrap-purify)))
|
||||
|
||||
(use-package! yasnippet-capf
|
||||
:when (modulep! :editor snippets)
|
||||
|
@ -139,9 +145,11 @@ Possible values are:
|
|||
(add-hook 'completion-at-point-functions #'yasnippet-capf 30 t))))
|
||||
|
||||
(use-package! corfu-terminal
|
||||
:when (modulep! :os tty)
|
||||
:when (not (display-graphic-p))
|
||||
:hook ((corfu-mode . corfu-terminal-mode)))
|
||||
|
||||
|
||||
;;
|
||||
;;; Extensions
|
||||
|
||||
|
@ -154,3 +162,22 @@ Possible values are:
|
|||
:hook ((corfu-mode . corfu-popupinfo-mode))
|
||||
:config
|
||||
(setq corfu-popupinfo-delay '(0.5 . 1.0)))
|
||||
|
||||
(use-package! nerd-icons-corfu
|
||||
:when (modulep! +icons)
|
||||
:defer t
|
||||
:init
|
||||
(after! corfu
|
||||
(add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter)))
|
||||
|
||||
;; If vertico is not enabled, orderless will be installed but not configured.
|
||||
;; That may break smart separator behavior, so we conditionally configure it.
|
||||
(use-package! orderless
|
||||
:when (and (not (modulep! :completion vertico))
|
||||
(modulep! +orderless))
|
||||
:config
|
||||
(setq completion-styles '(orderless basic)
|
||||
completion-category-defaults nil
|
||||
completion-category-overrides '((file (styles orderless partial-completion)))
|
||||
orderless-component-separator #'orderless-escapable-split-on-space)
|
||||
(set-face-attribute 'completions-first-difference nil :inherit nil))
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; completion/corfu/packages.el
|
||||
|
||||
(package! corfu :pin "b48d3017a47706198e04440cc1b3483bdf646771")
|
||||
(package! cape :pin "bfde79ed440343c0dbf0f64cfe7913c1efbe3f83")
|
||||
(package! corfu :pin "c1e7b6190b00158e67347b4db0a8f7964e5d2f8b")
|
||||
(package! cape :pin "a397a0c92de38277b7f835fa999fac400a764908")
|
||||
(when (modulep! +icons)
|
||||
(package! nerd-icons-corfu :pin "7077bb76fefc15aed967476406a19dc5c2500b3c"))
|
||||
(when (modulep! +orderless)
|
||||
|
@ -10,4 +10,4 @@
|
|||
(when (modulep! :os tty)
|
||||
(package! corfu-terminal :pin "501548c3d51f926c687e8cd838c5865ec45d03cc"))
|
||||
(when (modulep! :editor snippets)
|
||||
(package! yasnippet-capf :pin "db12b55cd08b614cbba134008566e48d7faf660e"))
|
||||
(package! yasnippet-capf :pin "9043f8275176a8f198ce8e81fadab1870fa165bb"))
|
||||
|
|
|
@ -252,6 +252,11 @@ orderless."
|
|||
(not (modulep! :checkers syntax +flymake)))
|
||||
:after (consult flycheck))
|
||||
|
||||
(use-package! consult-yasnippet
|
||||
:when (modulep! :editor snippets)
|
||||
:defer t
|
||||
:init (map! [remap yas-insert-snippet] #'consult-yasnippet))
|
||||
|
||||
|
||||
(use-package! embark
|
||||
:defer t
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; completion/vertico/packages.el
|
||||
|
||||
(package! vertico :pin "4a7da56b02c6aefff8f6b4574a530a7cb54bc21a")
|
||||
(package! vertico :pin "68cbd47589446e9674921bae0b98ff8fbe28be23")
|
||||
|
||||
(package! orderless :pin "b24748093b00b37c3a572c4909f61c08fa27504f")
|
||||
(package! orderless :pin "dc7a781acf2e58ac7d20d1b522be0cde5213e057")
|
||||
|
||||
(package! consult :pin "9463146ba754103db9475ae56e46561366ba4773")
|
||||
(package! consult :pin "b48ff6bf0527baeb6bfd07c6da9d303ff0b79c3d")
|
||||
(package! consult-dir :pin "3f5f4b71ebe819392cb090cda71bd39a93bd830a")
|
||||
(when (and (modulep! :checkers syntax)
|
||||
(not (modulep! :checkers syntax +flymake)))
|
||||
(package! consult-flycheck :pin "d83f87581af74f7a2739d8b1b90c37da5ae3d310"))
|
||||
(package! embark :pin "60139db8794f7e4a08076d9f7597d08f6c8083d1")
|
||||
(package! embark-consult :pin "60139db8794f7e4a08076d9f7597d08f6c8083d1")
|
||||
(package! consult-flycheck :pin "754f5497d827f7d58009256a21af614cc44378a3"))
|
||||
(package! embark :pin "c93abadc8220c0caa6fea805f7a736c346d47e7e")
|
||||
(package! embark-consult :pin "c93abadc8220c0caa6fea805f7a736c346d47e7e")
|
||||
|
||||
(package! marginalia :pin "ea356ebb1ddb8d6da78574b517155475cf52d46f")
|
||||
(package! marginalia :pin "f6fe86b989a177355ab3ff7e97a384e10a7b0bb1")
|
||||
|
||||
(package! wgrep :pin "208b9d01cfffa71037527e3a324684b3ce45ddc4")
|
||||
|
||||
|
@ -24,3 +24,6 @@
|
|||
(package! vertico-posframe
|
||||
:recipe (:host github :repo "tumashu/vertico-posframe")
|
||||
:pin "2e0e09e5bbd6ec576ddbe566ab122575ef051fab"))
|
||||
|
||||
(when (modulep! :editor snippets)
|
||||
(package! consult-yasnippet :pin "834d39acfe8a7d2c304afbe4d649b9372118c756"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue