fix(vertico): add counsel-file-jump analogue
Fix 'SPC f F' / 'C-c f F' for vertico users
This commit is contained in:
parent
551e5adf81
commit
33b646826b
4 changed files with 28 additions and 5 deletions
|
@ -129,8 +129,8 @@ If DIR is not a project, it will be indexed (but not cached)."
|
|||
#'counsel-projectile-find-file
|
||||
#'projectile-find-file)))
|
||||
((and (bound-and-true-p vertico-mode)
|
||||
(fboundp 'consult-find))
|
||||
(consult-find default-directory))
|
||||
(fboundp '+vertico/find-file-in))
|
||||
(+vertico/find-file-in default-directory))
|
||||
((and (bound-and-true-p ivy-mode)
|
||||
(fboundp 'counsel-file-jump))
|
||||
(call-interactively #'counsel-file-jump))
|
||||
|
|
|
@ -155,3 +155,25 @@ Supports exporting consult-grep to wgrep, file to wdeired, and consult-location
|
|||
(interactive)
|
||||
(vertico-previous (or n 1))
|
||||
(+vertico/embark-preview))
|
||||
|
||||
(defvar +vertico/find-file-in--history nil)
|
||||
;;;###autoload
|
||||
(defun +vertico/find-file-in (&optional dir initial)
|
||||
"Jump to file under DIR (recursive).
|
||||
If INITIAL is non-nil, use as initial input."
|
||||
(interactive)
|
||||
(let* ((default-directory (or dir default-directory))
|
||||
(prompt-dir (consult--directory-prompt "Find" default-directory))
|
||||
(cmd (split-string-and-unquote consult-find-command " "))
|
||||
(cmd (remove "OPTS" cmd))
|
||||
(cmd (remove "ARG" cmd)))
|
||||
(find-file
|
||||
(consult--read
|
||||
(split-string (cdr (apply #'doom-call-process cmd)) "\n" t)
|
||||
:prompt default-directory
|
||||
:sort nil
|
||||
:require-match t
|
||||
:initial (if initial (shell-quote-argument initial))
|
||||
:add-history (thing-at-point 'filename)
|
||||
:category '+vertico
|
||||
:history '(:input +vertico/find-file-in--history)))))
|
||||
|
|
|
@ -34,9 +34,7 @@
|
|||
(defun +default/find-file-under-here ()
|
||||
"Perform a recursive file search from the current directory."
|
||||
(interactive)
|
||||
(if (featurep! :completion ivy)
|
||||
(call-interactively #'counsel-file-jump)
|
||||
(doom-project-find-file default-directory)))
|
||||
(doom-project-find-file default-directory))
|
||||
|
||||
;;;###autoload
|
||||
(defun +default/discover-projects (arg)
|
||||
|
|
|
@ -280,6 +280,9 @@ otherwise falling back to ffap.el (find-file-at-point)."
|
|||
((and (featurep! :completion ivy)
|
||||
(doom-project-p))
|
||||
(counsel-file-jump guess (doom-project-root)))
|
||||
((and (featurep! :completion vertico)
|
||||
(doom-project-p))
|
||||
(+vertico/find-file-in (doom-project-root) guess))
|
||||
((find-file-at-point (ffap-prompter guess))))
|
||||
t))
|
||||
|
||||
|
|
Loading…
Reference in a new issue