diff --git a/modules/config/default/+evil-bindings.el b/modules/config/default/+evil-bindings.el index 22669d694..7871c269e 100644 --- a/modules/config/default/+evil-bindings.el +++ b/modules/config/default/+evil-bindings.el @@ -547,15 +547,11 @@ (:prefix ("/" . "search") :desc "Jump to symbol across buffers" "I" #'imenu-anywhere :desc "Search buffer" "b" #'swiper - :desc "Search current directory" "d" - (cond ((featurep! :completion ivy) #'+ivy/project-search-from-cwd) - ((featurep! :completion helm) #'+helm/project-search-from-cwd)) + :desc "Search current directory" "d" #'+default/search-from-cwd :desc "Jump to symbol" "i" #'imenu :desc "Jump to link" "l" #'ace-link :desc "Look up online" "o" #'+lookup/online-select - :desc "Search project" "p" - (cond ((featurep! :completion ivy) #'+ivy/project-search) - ((featurep! :completion helm) #'+helm/project-search))) + :desc "Search project" "p" #'+default/search-project) (:when (featurep! :feature workspaces) (:prefix ("TAB" . "workspace") diff --git a/modules/config/default/autoload/default.el b/modules/config/default/autoload/default.el index 8ee64bbea..dcdce7fb3 100644 --- a/modules/config/default/autoload/default.el +++ b/modules/config/default/autoload/default.el @@ -218,3 +218,34 @@ possible, or just one char if that's not possible." ((doom--backward-delete-whitespace-to-column))))))) ;; Otherwise, do simple deletion. ((delete-char (- n) killflag)))) + +;;;###autoload +(defun +default/search-from-cwd (&optional arg) + "Conduct a text search in files under the current folder. +If prefix ARG is set, prompt for a directory to search from." + (interactive "P") + (let ((default-directory + (if arg + (read-directory-name "Switch to project: " default-directory) + default-directory))) + (call-interactively + (cond ((featurep! :completion ivy) #'+ivy/project-search-from-cwd) + ((featurep! :completion helm) #'+helm/project-search-from-cwd) + (#'projectile-grep))))) + +;;;###autoload +(defun +default/search-project (&optional arg) + "Conduct a text search in files under the project root. +If prefix ARG is set, prompt for a project to search from." + (interactive "P") + (let ((default-directory + (if arg + (if-let* ((projects (projectile-relevant-known-projects))) + (completing-read "Switch to project: " projects + nil t nil nil (doom-project-root)) + (user-error "There are no known projects")) + default-directory))) + (call-interactively + (cond ((featurep! :completion ivy) #'+ivy/project-search) + ((featurep! :completion helm) #'+helm/project-search) + (#'rgrep)))))