Refactor completion/ivy & optimize projectile-find-file
counsel-projectile-find-file fontifies visited files and sorts the resulting file list from projectile-find-file, adding considerable overhead. Then, ivy-prescient performs a frecency sort and filter, adding more overhead. Altogether, this makes projectile-find-file unusable for larger projects when fuzzy search is on (and in some extreme cases, when it's off). This change disables both features specifically for projectile-find-file. Fixes #774, hopefully
This commit is contained in:
parent
3673067736
commit
ab4052b8dc
1 changed files with 38 additions and 33 deletions
|
@ -65,6 +65,9 @@ immediately runs it on the current candidate (ending the ivy session)."
|
||||||
(t . ivy--regex-fuzzy))
|
(t . ivy--regex-fuzzy))
|
||||||
ivy-initial-inputs-alist nil))
|
ivy-initial-inputs-alist nil))
|
||||||
|
|
||||||
|
;; make projectile-find-file faster
|
||||||
|
(add-to-list 'ivy-sort-functions-alist '(projectile-find-file))
|
||||||
|
|
||||||
(after! yasnippet
|
(after! yasnippet
|
||||||
(add-to-list 'yas-prompt-functions #'+ivy-yas-prompt nil #'eq))
|
(add-to-list 'yas-prompt-functions #'+ivy-yas-prompt nil #'eq))
|
||||||
|
|
||||||
|
@ -73,16 +76,20 @@ immediately runs it on the current candidate (ending the ivy session)."
|
||||||
[remap persp-switch-to-buffer] #'+ivy/switch-workspace-buffer
|
[remap persp-switch-to-buffer] #'+ivy/switch-workspace-buffer
|
||||||
[remap imenu-anywhere] #'ivy-imenu-anywhere)
|
[remap imenu-anywhere] #'ivy-imenu-anywhere)
|
||||||
|
|
||||||
(ivy-mode +1))
|
(ivy-mode +1)
|
||||||
|
|
||||||
|
;; Show more buffer information in switch-buffer commands
|
||||||
|
(after! ivy-rich
|
||||||
|
(dolist (cmd '(ivy-switch-buffer +ivy/switch-workspace-buffer
|
||||||
|
counsel-projectile-switch-to-buffer))
|
||||||
|
(ivy-set-display-transformer cmd '+ivy-buffer-transformer)))
|
||||||
|
|
||||||
;; Show more buffer information in switch-buffer commands
|
(def-package! ivy-hydra
|
||||||
(def-package! ivy-rich
|
:commands (ivy-dispatching-done-hydra ivy--matcher-desc)
|
||||||
:after ivy
|
:init
|
||||||
:config
|
(define-key! ivy-minibuffer-map
|
||||||
(dolist (cmd '(ivy-switch-buffer +ivy/switch-workspace-buffer
|
"\C-o" #'+ivy-coo-hydra/body
|
||||||
counsel-projectile-switch-to-buffer))
|
(kbd "M-o") #'ivy-dispatching-done-hydra)))
|
||||||
(ivy-set-display-transformer cmd '+ivy-buffer-transformer)))
|
|
||||||
|
|
||||||
|
|
||||||
(def-package! counsel
|
(def-package! counsel
|
||||||
|
@ -147,11 +154,9 @@ immediately runs it on the current candidate (ending the ivy session)."
|
||||||
("L" (lambda (path) "Insert org-link with absolute path"
|
("L" (lambda (path) "Insert org-link with absolute path"
|
||||||
(with-ivy-window (insert (format "[[%s]]" path)))) "insert org-link (abs. path)")))
|
(with-ivy-window (insert (format "[[%s]]" path)))) "insert org-link (abs. path)")))
|
||||||
|
|
||||||
;; Configure `counsel-rg', `counsel-ag' & `counsel-pt'
|
(ivy-add-actions
|
||||||
(dolist (cmd '(counsel-ag counsel-rg counsel-pt))
|
'counsel-ag ; also applies to `counsel-rg' & `counsel-pt'
|
||||||
(ivy-add-actions
|
'(("O" +ivy-git-grep-other-window-action "open in other window"))))
|
||||||
cmd
|
|
||||||
'(("O" +ivy-git-grep-other-window-action "open in other window")))))
|
|
||||||
|
|
||||||
|
|
||||||
(def-package! counsel-projectile
|
(def-package! counsel-projectile
|
||||||
|
@ -166,17 +171,30 @@ immediately runs it on the current candidate (ending the ivy session)."
|
||||||
[remap projectile-ag] #'counsel-projectile-ag
|
[remap projectile-ag] #'counsel-projectile-ag
|
||||||
[remap projectile-switch-project] #'counsel-projectile-switch-project)
|
[remap projectile-switch-project] #'counsel-projectile-switch-project)
|
||||||
:config
|
:config
|
||||||
;; Highlight entries that have been visited
|
;; Highlight entries that have been visited; opposite of default
|
||||||
(ivy-set-display-transformer #'counsel-projectile-find-file #'+ivy-projectile-find-file-transformer))
|
(ivy-set-display-transformer #'counsel-projectile-find-file #'+ivy-projectile-find-file-transformer))
|
||||||
|
|
||||||
|
|
||||||
(def-package! ivy-hydra
|
(def-package! ivy-prescient
|
||||||
:commands (ivy-dispatching-done-hydra ivy--matcher-desc)
|
:after ivy
|
||||||
:init
|
:init
|
||||||
(after! ivy
|
(if (featurep! +fuzzy)
|
||||||
(define-key! ivy-minibuffer-map
|
(setq prescient-filter-method 'fuzzy)
|
||||||
"\C-o" #'+ivy-coo-hydra/body
|
(setq prescient-filter-method 'regexp
|
||||||
(kbd "M-o") #'ivy-dispatching-done-hydra)))
|
ivy-prescient-retain-classic-highlighting t))
|
||||||
|
:config
|
||||||
|
(setq prescient-save-file (concat doom-cache-dir "presclient-save.el"))
|
||||||
|
|
||||||
|
;; `ivy-prescient' is too slow for fuzzy projectile-find-file and
|
||||||
|
;; counsel-file-jump, so ensure they're ignored
|
||||||
|
(when (featurep! +fuzzy)
|
||||||
|
(add-to-list 'ivy-re-builders-alist '(counsel-file-jump . +ivy--regex-fuzzy))
|
||||||
|
(add-to-list 'ivy-re-builders-alist '(projectile-find-file . +ivy--regex-fuzzy)))
|
||||||
|
(add-to-list 'ivy-prescient-excluded-commands 'counsel-find-jump nil #'eq)
|
||||||
|
(add-to-list 'ivy-prescient-excluded-commands 'projectile-find-file nil #'eq)
|
||||||
|
|
||||||
|
(prescient-persist-mode +1)
|
||||||
|
(ivy-prescient-mode +1))
|
||||||
|
|
||||||
|
|
||||||
(def-package! wgrep
|
(def-package! wgrep
|
||||||
|
@ -218,19 +236,6 @@ immediately runs it on the current candidate (ending the ivy session)."
|
||||||
(setf (alist-get fn ivy-display-functions-alist) #'ivy-display-function-fallback)))
|
(setf (alist-get fn ivy-display-functions-alist) #'ivy-display-function-fallback)))
|
||||||
|
|
||||||
|
|
||||||
(def-package! ivy-prescient
|
|
||||||
:after ivy
|
|
||||||
:init
|
|
||||||
(if (featurep! +fuzzy)
|
|
||||||
(setq prescient-filter-method 'fuzzy)
|
|
||||||
(setq prescient-filter-method 'regexp
|
|
||||||
ivy-prescient-retain-classic-highlighting t))
|
|
||||||
:config
|
|
||||||
(setq prescient-save-file (concat doom-cache-dir "presclient-save.el"))
|
|
||||||
(prescient-persist-mode +1)
|
|
||||||
(ivy-prescient-mode +1))
|
|
||||||
|
|
||||||
|
|
||||||
;; Used by `counsel-M-x'
|
;; Used by `counsel-M-x'
|
||||||
(setq amx-save-file (concat doom-cache-dir "amx-items"))
|
(setq amx-save-file (concat doom-cache-dir "amx-items"))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue