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
365a95de76
commit
0588b42b46
5 changed files with 31 additions and 2 deletions
|
@ -148,7 +148,10 @@ completing inserts a space as separator. This allows searching 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
|
||||
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.
|
||||
|
||||
| Keybind | Description |
|
||||
|---------+-------------------------------------------------|
|
||||
|
|
|
@ -8,3 +8,15 @@
|
|||
(let ((completion-extra-properties corfu--extra)
|
||||
(completion-cycle-threshold completion-cycling))
|
||||
(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 (call-interactively #'corfu-insert-separator))))
|
||||
|
|
|
@ -46,6 +46,7 @@ Possible values are:
|
|||
(add-to-list 'completion-category-overrides `(lsp-capf (styles ,@completion-styles)))
|
||||
(add-to-list 'corfu-auto-commands #'lispy-colon)
|
||||
(add-to-list 'corfu-continue-commands #'+corfu-move-to-minibuffer)
|
||||
(add-to-list 'corfu-continue-commands #'+corfu-smart-sep-toggle-escape)
|
||||
(add-hook 'evil-insert-state-exit-hook #'corfu-quit))
|
||||
|
||||
(use-package! cape
|
||||
|
@ -118,3 +119,15 @@ Possible values are:
|
|||
: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))
|
||||
|
|
|
@ -107,7 +107,7 @@ orderless."
|
|||
;; find-file etc.
|
||||
completion-category-overrides '((file (styles +vertico-basic-remote orderless partial-completion)))
|
||||
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
|
||||
(set-face-attribute 'completions-first-difference nil :inherit nil))
|
||||
|
||||
|
|
|
@ -461,6 +461,7 @@ Continues comments if executed from a commented line. Consults
|
|||
(map! :when (modulep! :completion corfu)
|
||||
:after corfu
|
||||
(:map corfu-map
|
||||
[remap corfu-insert-separator] #'+corfu-smart-sep-toggle-escape
|
||||
"C-S-s" #'+corfu-move-to-minibuffer
|
||||
"C-p" #'corfu-previous
|
||||
"C-n" #'corfu-next
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue