selectrum: refactor orderless configuration
- unify `setq`'s - move style dispatch functions into the `use-package`, rename them to follow doom conventions
This commit is contained in:
parent
c1cbfa03f7
commit
56d6dc5e77
1 changed files with 20 additions and 19 deletions
|
@ -42,18 +42,6 @@
|
||||||
(add-hook 'selectrum-candidate-selected-hook #'selectrum-prescient--remember)
|
(add-hook 'selectrum-candidate-selected-hook #'selectrum-prescient--remember)
|
||||||
(add-hook 'selectrum-candidate-inserted-hook #'selectrum-prescient--remember))
|
(add-hook 'selectrum-candidate-inserted-hook #'selectrum-prescient--remember))
|
||||||
|
|
||||||
(defun flex-if-twiddle (pattern _index _total)
|
|
||||||
(when (string-suffix-p "~" pattern)
|
|
||||||
`(orderless-flex . ,(substring pattern 0 -1))))
|
|
||||||
|
|
||||||
(defun first-initialism (pattern index _total)
|
|
||||||
(if (= index 0) 'orderless-initialism))
|
|
||||||
|
|
||||||
(defun without-if-bang (pattern _index _total)
|
|
||||||
"Define a '!not' exclusion prefix for literal strings."
|
|
||||||
(when (string-prefix-p "!" pattern)
|
|
||||||
`(orderless-without-literal . ,(substring pattern 1))))
|
|
||||||
|
|
||||||
(use-package! orderless
|
(use-package! orderless
|
||||||
:when (not (featurep! +prescient))
|
:when (not (featurep! +prescient))
|
||||||
:after selectrum
|
:after selectrum
|
||||||
|
@ -63,13 +51,26 @@
|
||||||
orderless-initialism
|
orderless-initialism
|
||||||
orderless-regexp))
|
orderless-regexp))
|
||||||
:config
|
:config
|
||||||
(setq completion-styles '(orderless))
|
(defun +selectrum--orderless-flex-if-twiddle (pattern _index _total)
|
||||||
(setq orderless-skip-highlighting (lambda () selectrum-is-active))
|
(when (string-suffix-p "~" pattern)
|
||||||
(setq selectrum-refine-candidates-function #'orderless-filter)
|
`(orderless-flex . ,(substring pattern 0 -1))))
|
||||||
(setq selectrum-highlight-candidates-function #'orderless-highlight-matches)
|
|
||||||
(setq orderless-matching-styles '(orderless-regexp)
|
(defun +selectrum--orderless-first-initialism (pattern index _total)
|
||||||
orderless-style-dispatchers '(flex-if-twiddle
|
(if (= index 0) 'orderless-initialism))
|
||||||
without-if-bang)))
|
|
||||||
|
(defun +selectrum--orderless-without-if-bang (pattern _index _total)
|
||||||
|
"Define a '!not' exclusion prefix for literal strings."
|
||||||
|
(when (string-prefix-p "!" pattern)
|
||||||
|
`(orderless-without-literal . ,(substring pattern 1))))
|
||||||
|
|
||||||
|
(setq completion-styles '(orderless)
|
||||||
|
orderless-skip-highlighting (lambda () selectrum-is-active)
|
||||||
|
selectrum-refine-candidates-function #'orderless-filter
|
||||||
|
selectrum-highlight-candidates-function #'orderless-highlight-matches
|
||||||
|
orderless-matching-styles '(orderless-regexp)
|
||||||
|
orderless-style-dispatchers '(+selectrum--orderless-flex-if-twiddle
|
||||||
|
+selectrum--orderless-first-initialism
|
||||||
|
+selectrum--orderless-without-if-bang)))
|
||||||
|
|
||||||
(use-package! consult
|
(use-package! consult
|
||||||
:defer t
|
:defer t
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue