diff --git a/modules/completion/helm/autoload/helm.el b/modules/completion/helm/autoload/helm.el index ce8e3b9ea..533e21eb8 100644 --- a/modules/completion/helm/autoload/helm.el +++ b/modules/completion/helm/autoload/helm.el @@ -33,9 +33,9 @@ order. (helm-ag--default-directory directory) (helm-ag--default-target (list directory)) (engine (or engine - (and (executable-find "rg") 'rg) - (and (executable-find "ag") 'ag) - (and (executable-find "pt") 'pt) + (cl-loop for tool in +ivy-project-search-engines + if (executable-find (symbol-name tool)) + return tool) (and (or (executable-find "grep") (executable-find "git")) 'grep) @@ -131,11 +131,12 @@ list of: ripgrep, ag, pt, git-grep and grep. If ARG (universal argument), preform search from current directory." (interactive "P") (call-interactively - (cond ((executable-find "rg") (if arg #'+helm/rg-from-cwd #'+helm/rg)) - ((executable-find "ag") (if arg #'+helm/ag-from-cwd #'+helm/ag)) - ((executable-find "pt") (if arg #'+helm/pt-from-cwd #'+helm/pt)) - (arg #'+helm/grep-from-cwd) - (#'+helm/grep)))) + (or (cl-loop for tool in (cl-remove-duplicates +ivy-project-search-engines) + if (executable-find (symbol-name tool)) + return (intern (format "+helm/%s%s" tool (if arg "-from-cwd" "")))) + (if arg + #'+helm/grep-from-cwd + #'+helm/grep)))) ;; Relative to project root ;;;###autoload diff --git a/modules/completion/helm/config.el b/modules/completion/helm/config.el index 27e17e721..9a1a0faea 100644 --- a/modules/completion/helm/config.el +++ b/modules/completion/helm/config.el @@ -3,6 +3,16 @@ (defvar +helm-global-prompt "››› " "The helm text prompt prefix string is globally replaced with this string.") +(defvar +helm-project-search-engines '(rg ag pt) + "What search tools for `+helm/project-search' (and `+helm-file-search' when no +ENGINE is specified) to try, and in what order. + +To disable a particular tool, remove it from this list. To prioritize a tool +over others, move it to the front of the list. Later duplicates in this list are +silently ignored. + +If you want to already use git-grep or grep, set this to nil.") + ;; ;; Packages diff --git a/modules/completion/ivy/autoload/ivy.el b/modules/completion/ivy/autoload/ivy.el index 84cf3c1f0..094f8400c 100644 --- a/modules/completion/ivy/autoload/ivy.el +++ b/modules/completion/ivy/autoload/ivy.el @@ -224,9 +224,9 @@ order. (directory (or in project-root)) (default-directory directory) (engine (or engine - (and (executable-find "rg") 'rg) - (and (executable-find "ag") 'ag) - (and (executable-find "pt") 'pt) + (cl-loop for tool in +ivy-project-search-engines + if (executable-find (symbol-name tool)) + return tool) (and (or (executable-find "grep") (executable-find "git")) 'grep) @@ -285,11 +285,12 @@ list of: ripgrep, ag, pt, git-grep and grep. If ARG (universal argument), preform search from current directory." (interactive "P") (call-interactively - (cond ((executable-find "rg") (if arg #'+ivy/rg-from-cwd #'+ivy/rg)) - ((executable-find "ag") (if arg #'+ivy/ag-from-cwd #'+ivy/ag)) - ((executable-find "pt") (if arg #'+ivy/pt-from-cwd #'+ivy/pt)) - (arg #'+ivy/grep-from-cwd) - (#'+ivy/grep)))) + (or (cl-loop for tool in (cl-remove-duplicates +ivy-project-search-engines) + if (executable-find (symbol-name tool)) + return (intern (format "+ivy/%s%s" tool (if arg "-from-cwd" "")))) + (if arg + #'+ivy/grep-from-cwd + #'+ivy/grep)))) ;;;###autoload (defun +ivy/rg (all-files-p &optional query directory) diff --git a/modules/completion/ivy/config.el b/modules/completion/ivy/config.el index 409df5fca..c68bed7ef 100644 --- a/modules/completion/ivy/config.el +++ b/modules/completion/ivy/config.el @@ -9,6 +9,16 @@ "An alist of tags for `+ivy/tasks' to include in its search, whose CDR is the face to render it with.") +(defvar +ivy-project-search-engines '(rg ag pt) + "What search tools for `+ivy/project-search' (and `+ivy-file-search' when no +ENGINE is specified) to try, and in what order. + +To disable a particular tool, remove it from this list. To prioritize a tool +over others, move it to the front of the list. Later duplicates in this list are +silently ignored. + +If you want to already use git-grep or grep, set this to nil.") + (defmacro +ivy-do-action! (action) "Returns an interactive lambda that sets the current ivy action and immediately runs it on the current candidate (ending the ivy session)."