feat(corfu, vertico): use equal orderless config
This removes the old `&` separator for Vertico (does anyone use that instead of just space?) in favor of escapable space and unifies orderless config with Corfu. Also implements smart separator insert/escape/reset on `C-SPC` Co-authored-by: Liam Hupfer <liam@hpfr.net>
This commit is contained in:
parent
d265375368
commit
1787d06a2a
4 changed files with 54 additions and 35 deletions
|
@ -71,25 +71,25 @@ By default, completion gets triggered after typing 2 non-space consecutive
|
||||||
characters, or by means of the [[kbd:][C-SPC]] keybinding at any moment. While the popup
|
characters, or by means of the [[kbd:][C-SPC]] keybinding at any moment. While the popup
|
||||||
is visible, the following relevant keys are available:
|
is visible, the following relevant keys are available:
|
||||||
|
|
||||||
| Keybind | Description |
|
| Keybind | Description |
|
||||||
|----------+---------------------------------------------------------|
|
|----------+------------------------------------------------------------------|
|
||||||
| [[kbd:][<down>]] | Go to next candidate |
|
| [[kbd:][<down>]] | Go to next candidate |
|
||||||
| [[kbd:][<up>]] | Go to previous candidate |
|
| [[kbd:][<up>]] | Go to previous candidate |
|
||||||
| [[kbd:][C-n]] | Go to next candidate |
|
| [[kbd:][C-n]] | Go to next candidate |
|
||||||
| [[kbd:][C-p]] | Go to previous candidate |
|
| [[kbd:][C-p]] | Go to previous candidate |
|
||||||
| [[kbd:][C-j]] | (evil) Go to next candidate |
|
| [[kbd:][C-j]] | (evil) Go to next candidate |
|
||||||
| [[kbd:][C-k]] | (evil) Go to previous candidate |
|
| [[kbd:][C-k]] | (evil) Go to previous candidate |
|
||||||
| [[kbd:][C-<down>]] | Go to next doc line |
|
| [[kbd:][C-<down>]] | Go to next doc line |
|
||||||
| [[kbd:][C-<up>]] | Go to previous doc line |
|
| [[kbd:][C-<up>]] | Go to previous doc line |
|
||||||
| [[kbd:][C-S-n]] | Go to next doc line |
|
| [[kbd:][C-S-n]] | Go to next doc line |
|
||||||
| [[kbd:][C-S-p]] | Go to previous doc line |
|
| [[kbd:][C-S-p]] | Go to previous doc line |
|
||||||
| [[kbd:][C-S-j]] | (evil) Go to next doc line |
|
| [[kbd:][C-S-j]] | (evil) Go to next doc line |
|
||||||
| [[kbd:][C-S-k]] | (evil) Go to previous doc line |
|
| [[kbd:][C-S-k]] | (evil) Go to previous doc line |
|
||||||
| [[kbd:][C-h]] | Toggle documentation (if available) |
|
| [[kbd:][C-h]] | Toggle documentation (if available) |
|
||||||
| [[kbd:][M-m]] | Export to minibuffer (if [[doom-module::completion vertico]]) |
|
| [[kbd:][M-m]] | Export to minibuffer (if [[doom-module::completion vertico]]) |
|
||||||
| [[kbd:][M-j]] | (evil) Export to minibuffer (if [[doom-module::completion vertico]]) |
|
| [[kbd:][M-j]] | (evil) Export to minibuffer (if [[doom-module::completion vertico]]) |
|
||||||
| [[kbd:][RET]] | Insert candidate |
|
| [[kbd:][RET]] | Insert candidate |
|
||||||
| [[kbd:][SPC]] | Quit autocompletion after a wildcard or pass-through |
|
| [[kbd:][SPC]] | Quit autocompletion after a wildcard or pass-through |
|
||||||
| [[kbd:][C-SPC]] | Complete (unless [[doom-module::completion corfu +tng]]) |
|
| [[kbd:][C-SPC]] | Complete (unless [[doom-module::completion corfu +tng]]) |
|
||||||
| [[kbd:][C-SPC]] | (when completing) Insert separator DWIM (see below) |
|
| [[kbd:][C-SPC]] | (when completing) Insert separator DWIM (see below) |
|
||||||
|
|
||||||
|
@ -112,7 +112,10 @@ completing inserts a space as separator. This allows searching with
|
||||||
space-separated terms; each piece will match individually and in any order, with
|
space-separated terms; each piece will match individually and in any order, with
|
||||||
smart casing. Pressing just [[kbd:][SPC]] acts as normal and quits completion, so that
|
smart casing. Pressing just [[kbd:][SPC]] acts as normal and quits completion, so that
|
||||||
when typing sentences it doesn't try to complete the whole sentence instead of
|
when typing sentences it doesn't try to complete the whole sentence instead of
|
||||||
just the word.
|
just the word. Pressing [[kdb:][C-SPC]] with point after a separator escapes it with a
|
||||||
|
backslash, including the space in the search term, and pressing it with an
|
||||||
|
already escaped separator before point deletes it. Thus, you can cycle back if
|
||||||
|
you accidentaly press more than needed.
|
||||||
|
|
||||||
Additionally, for users of evil and regular corfu style, [[kdb:][C-SPC]] is smart
|
Additionally, for users of evil and regular corfu style, [[kdb:][C-SPC]] is smart
|
||||||
regarding your state. In normal-like states, enter insert then start corfu; in
|
regarding your state. In normal-like states, enter insert then start corfu; in
|
||||||
|
|
|
@ -8,3 +8,18 @@
|
||||||
(let ((completion-extra-properties corfu--extra)
|
(let ((completion-extra-properties corfu--extra)
|
||||||
(completion-cycle-threshold completion-cycling))
|
(completion-cycle-threshold completion-cycling))
|
||||||
(apply #'consult-completion-in-region completion-in-region--data)))
|
(apply #'consult-completion-in-region completion-in-region--data)))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +corfu-smart-sep-toggle-escape ()
|
||||||
|
"Insert `corfu-separator' or toggle escape if it's already there."
|
||||||
|
(interactive)
|
||||||
|
(cond ((and (char-equal (char-before) corfu-separator)
|
||||||
|
(char-equal (char-before (1- (point))) ?\\))
|
||||||
|
(save-excursion (delete-char -2)))
|
||||||
|
((char-equal (char-before) corfu-separator)
|
||||||
|
(save-excursion (backward-char 1)
|
||||||
|
(insert-char ?\\)))
|
||||||
|
(t
|
||||||
|
;; Without this corfu quits immediately.
|
||||||
|
(setq this-command #'corfu-insert-separator)
|
||||||
|
(call-interactively #'corfu-insert-separator))))
|
||||||
|
|
|
@ -57,26 +57,27 @@
|
||||||
(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))
|
||||||
|
|
||||||
(map! :map corfu-map
|
(let ((cmds-del (cmds! (and (modulep! +tng)
|
||||||
[return] #'corfu-insert
|
(> corfu--index -1)
|
||||||
"RET" #'corfu-insert)
|
(eq corfu-preview-current 'insert))
|
||||||
(when (modulep! +orderless)
|
#'corfu-reset)))
|
||||||
(map! :map corfu-map
|
(map! :map corfu-map
|
||||||
"C-SPC" #'corfu-insert-separator))
|
[return] #'corfu-insert
|
||||||
(when (modulep! +tng)
|
"RET" #'corfu-insert
|
||||||
(map! :map corfu-map
|
(:when (modulep! +orderless)
|
||||||
[tab] #'corfu-next
|
"<remap> <completion-at-point>" #'+corfu-smart-sep-toggle-escape)
|
||||||
[backtab] #'corfu-previous
|
(:when (modulep! +tng)
|
||||||
"TAB" #'corfu-next
|
[tab] #'corfu-next
|
||||||
"S-TAB" #'corfu-previous)
|
[backtab] #'corfu-previous
|
||||||
(let ((cmds-del (cmds! (and (modulep! +tng)
|
"TAB" #'corfu-next
|
||||||
(> corfu--index -1)
|
"S-TAB" #'corfu-previous
|
||||||
(eq corfu-preview-current 'insert))
|
|
||||||
#'corfu-reset)))
|
|
||||||
(map! :map corfu-map
|
|
||||||
[backspace] cmds-del
|
[backspace] cmds-del
|
||||||
"DEL" cmds-del)))
|
"DEL" cmds-del)))
|
||||||
|
|
||||||
|
(when (modulep! +orderless)
|
||||||
|
(after! orderless
|
||||||
|
(setq orderless-component-separator #'orderless-escapable-split-on-space)))
|
||||||
|
|
||||||
(after! vertico
|
(after! vertico
|
||||||
(map! :map corfu-map
|
(map! :map corfu-map
|
||||||
"M-m" #'+corfu-move-to-minibuffer
|
"M-m" #'+corfu-move-to-minibuffer
|
||||||
|
|
|
@ -107,7 +107,7 @@ orderless."
|
||||||
;; find-file etc.
|
;; find-file etc.
|
||||||
completion-category-overrides '((file (styles +vertico-basic-remote orderless partial-completion)))
|
completion-category-overrides '((file (styles +vertico-basic-remote orderless partial-completion)))
|
||||||
orderless-style-dispatchers '(+vertico-orderless-dispatch)
|
orderless-style-dispatchers '(+vertico-orderless-dispatch)
|
||||||
orderless-component-separator "[ &]")
|
orderless-component-separator #'orderless-escapable-split-on-space)
|
||||||
;; ...otherwise find-file gets different highlighting than other commands
|
;; ...otherwise find-file gets different highlighting than other commands
|
||||||
(set-face-attribute 'completions-first-difference nil :inherit nil))
|
(set-face-attribute 'completions-first-difference nil :inherit nil))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue