Add +prescient option for :completion ivy
This provides an alternative backend for filtering and sorting ivy searches. Uses prescient instead of flx for fuzzy completion when both +prescient and +fuzzy are selected.
This commit is contained in:
parent
febeed2526
commit
2a511a6576
4 changed files with 37 additions and 4 deletions
|
@ -47,6 +47,7 @@
|
|||
(def-package! company-prescient
|
||||
:hook (company-mode . company-prescient-mode)
|
||||
:config
|
||||
;; NOTE prescient config duplicated with `ivy'
|
||||
(setq prescient-save-file (concat doom-cache-dir "prescient-save.el"))
|
||||
(prescient-persist-mode +1))
|
||||
|
||||
|
|
|
@ -37,7 +37,8 @@ lighter, simpler and faster in many cases.
|
|||
#+end_quote
|
||||
|
||||
** Module Flags
|
||||
+ =+fuzzy= Enables the fuzzy method for ivy searches.
|
||||
+ =+fuzzy= Enables fuzzy completion for Ivy searches.
|
||||
+ =+prescient= Enables prescient filtering and sorting for Ivy searches.
|
||||
+ =+childframe= Causes Ivy to display in a floating child frame, above Emacs.
|
||||
*This requires GUI Emacs 26.1+*
|
||||
+ =+icons= Enables file icons for switch-{buffer,project}/find-file counsel
|
||||
|
@ -53,6 +54,7 @@ lighter, simpler and faster in many cases.
|
|||
+ [[https://github.com/mhayashi1120/Emacs-wgrep][wgrep]]
|
||||
+ [[https://github.com/DarwinAwardWinner/amx][amx]]
|
||||
+ [[https://github.com/lewang/flx][flx]]* (=+fuzzy=)
|
||||
+ [[https://github.com/raxod502/prescient.el][prescient]]* (=+prescient=)
|
||||
+ [[https://github.com/tumashu/ivy-posframe][ivy-posframe]]* (=+childframe=)
|
||||
+ [[https://github.com/asok/all-the-icons-ivy][all-the-icons-ivy]]* (=+icons=)
|
||||
|
||||
|
|
|
@ -294,7 +294,8 @@ immediately runs it on the current candidate (ending the ivy session)."
|
|||
|
||||
|
||||
(def-package! flx
|
||||
:when (featurep! +fuzzy)
|
||||
:when (and (featurep! +fuzzy)
|
||||
(not (featurep! +prescient)))
|
||||
:defer t ; is loaded by ivy
|
||||
:init
|
||||
(setq ivy-re-builders-alist
|
||||
|
@ -307,6 +308,33 @@ immediately runs it on the current candidate (ending the ivy session)."
|
|||
ivy-initial-inputs-alist nil))
|
||||
|
||||
|
||||
(def-package! ivy-prescient
|
||||
:hook (ivy-mode . ivy-prescient-mode)
|
||||
:when (featurep! +prescient)
|
||||
:init
|
||||
(setq prescient-filter-method (if (featurep! +fuzzy)
|
||||
'(literal regexp initialism fuzzy)
|
||||
'(literal regexp initialism))
|
||||
ivy-prescient-enable-filtering nil ;; we do this ourselves
|
||||
ivy-initial-inputs-alist nil
|
||||
ivy-re-builders-alist
|
||||
'((counsel-ag . +ivy-prescient-non-fuzzy)
|
||||
(counsel-rg . +ivy-prescient-non-fuzzy)
|
||||
(counsel-grep . +ivy-prescient-non-fuzzy)
|
||||
(swiper . +ivy-prescient-non-fuzzy)
|
||||
(swiper-isearch . +ivy-prescient-non-fuzzy)
|
||||
(t . ivy-prescient-re-builder)))
|
||||
|
||||
:config
|
||||
(defun +ivy-prescient-non-fuzzy (str)
|
||||
(let ((prescient-filter-method '(literal regexp)))
|
||||
(ivy-prescient-re-builder str)))
|
||||
|
||||
;; NOTE prescient config duplicated with `company'
|
||||
(setq prescient-save-file (concat doom-cache-dir "prescient-save.el"))
|
||||
(prescient-persist-mode +1))
|
||||
|
||||
|
||||
;; Used by `counsel-M-x'
|
||||
(setq amx-save-file (concat doom-cache-dir "amx-items"))
|
||||
|
||||
|
|
|
@ -10,8 +10,10 @@
|
|||
(package! ivy-rich)
|
||||
(package! wgrep)
|
||||
|
||||
(if (featurep! +prescient)
|
||||
(package! ivy-prescient)
|
||||
(when (featurep! +fuzzy)
|
||||
(package! flx))
|
||||
(package! flx)))
|
||||
|
||||
(when (and EMACS26+ (featurep! +childframe))
|
||||
(package! ivy-posframe))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue