Skip to content

Commit 273f0db

Browse files
committed
fix(fzf): add support for searching the current project via project.el
1 parent d135281 commit 273f0db

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

modules/me-tools.el

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,18 @@
2727
"szg" #'fzf-grep
2828
"szG" #'fzf-grep-dwim
2929
"szf" #'fzf-find-file
30-
"szF" #'fzf-find-file-in-dir))
30+
"szF" #'fzf-find-file-in-dir)
31+
:config
32+
(defun fzf-project (&optional with-preview)
33+
"Starts an fzf session at the root of the current project."
34+
(interactive "P")
35+
(let ((fzf/args (if with-preview (concat fzf/args " " fzf/args-for-preview) fzf/args))
36+
(fzf--target-validator (fzf--use-validator (function fzf--validate-filename))))
37+
(fzf--start (or (ignore-errors (project-root (project-current))) default-directory) #'fzf--action-find-file)))
38+
39+
;; fzf.el relays on `projectile-project-root' to guess the project root
40+
(unless (fboundp 'projectile-project-root)
41+
(defalias 'projectile-project-root (lambda () (ignore-errors (project-root (project-current)))))))
3142

3243
(use-package tldr
3344
:straight t

0 commit comments

Comments
 (0)