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:
parent
6b06cd32ac
commit
e865526c75
4 changed files with 38 additions and 16 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue