Skip to content

Commit 33b6468

Browse files
committed
fix(vertico): add counsel-file-jump analogue
Fix 'SPC f F' / 'C-c f F' for vertico users
1 parent 551e5ad commit 33b6468

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

core/autoload/projects.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ If DIR is not a project, it will be indexed (but not cached)."
129129
#'counsel-projectile-find-file
130130
#'projectile-find-file)))
131131
((and (bound-and-true-p vertico-mode)
132-
(fboundp 'consult-find))
133-
(consult-find default-directory))
132+
(fboundp '+vertico/find-file-in))
133+
(+vertico/find-file-in default-directory))
134134
((and (bound-and-true-p ivy-mode)
135135
(fboundp 'counsel-file-jump))
136136
(call-interactively #'counsel-file-jump))

modules/completion/vertico/autoload/vertico.el

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,25 @@ Supports exporting consult-grep to wgrep, file to wdeired, and consult-location
155155
(interactive)
156156
(vertico-previous (or n 1))
157157
(+vertico/embark-preview))
158+
159+
(defvar +vertico/find-file-in--history nil)
160+
;;;###autoload
161+
(defun +vertico/find-file-in (&optional dir initial)
162+
"Jump to file under DIR (recursive).
163+
If INITIAL is non-nil, use as initial input."
164+
(interactive)
165+
(let* ((default-directory (or dir default-directory))
166+
(prompt-dir (consult--directory-prompt "Find" default-directory))
167+
(cmd (split-string-and-unquote consult-find-command " "))
168+
(cmd (remove "OPTS" cmd))
169+
(cmd (remove "ARG" cmd)))
170+
(find-file
171+
(consult--read
172+
(split-string (cdr (apply #'doom-call-process cmd)) "\n" t)
173+
:prompt default-directory
174+
:sort nil
175+
:require-match t
176+
:initial (if initial (shell-quote-argument initial))
177+
:add-history (thing-at-point 'filename)
178+
:category '+vertico
179+
:history '(:input +vertico/find-file-in--history)))))

modules/config/default/autoload/files.el

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@
3434
(defun +default/find-file-under-here ()
3535
"Perform a recursive file search from the current directory."
3636
(interactive)
37-
(if (featurep! :completion ivy)
38-
(call-interactively #'counsel-file-jump)
39-
(doom-project-find-file default-directory)))
37+
(doom-project-find-file default-directory))
4038

4139
;;;###autoload
4240
(defun +default/discover-projects (arg)

modules/tools/lookup/autoload/lookup.el

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ otherwise falling back to ffap.el (find-file-at-point)."
280280
((and (featurep! :completion ivy)
281281
(doom-project-p))
282282
(counsel-file-jump guess (doom-project-root)))
283+
((and (featurep! :completion vertico)
284+
(doom-project-p))
285+
(+vertico/find-file-in (doom-project-root) guess))
283286
((find-file-at-point (ffap-prompter guess))))
284287
t))
285288

0 commit comments

Comments
 (0)