Add +(helm|ivy)-project-search-engines variables

This allows you to control what search engines for project-search
commands (bound to SPC / p) to try, and in what order. If you didn't
want to use ripgrep, for instance, remove 'rg from these variables, or
move it to the end of the list.
This commit is contained in:
Henrik Lissner 2018-07-23 00:06:47 +02:00
parent 6b06cd32ac
commit e865526c75
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
4 changed files with 38 additions and 16 deletions

View file

@ -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