From 3bc9f4b4fb5bb7daa1910ed808ffa8c9be1c5bc5 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 19 Feb 2018 20:18:25 -0500 Subject: [PATCH] completion/ivy: refactor ag/rg file search backends + fix args --- modules/completion/ivy/autoload/evil.el | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/modules/completion/ivy/autoload/evil.el b/modules/completion/ivy/autoload/evil.el index da25f046d..0fd467881 100644 --- a/modules/completion/ivy/autoload/evil.el +++ b/modules/completion/ivy/autoload/evil.el @@ -51,7 +51,8 @@ (pcase engine ('grep (let ((args (if recursion-p " -r")) - (counsel-projectile-grep-initial-input query)) + (counsel-projectile-grep-initial-input query) + (default-directory directory)) (if all-files-p (cl-letf (((symbol-function #'projectile-ignored-directories-rel) (symbol-function #'ignore)) @@ -60,17 +61,14 @@ (counsel-projectile-grep args)) (counsel-projectile-grep args)))) ('ag - (let ((args (concat - (if all-files-p " -a") - (unless recursion-p " -n")))) + (let ((args (concat " -S" ; smart-case + (if all-files-p " -a") + (unless recursion-p " --depth 1")))) (counsel-ag query directory args (format prompt args)))) ('rg - ;; smart-case instead of case-insensitive flag - (let ((counsel-rg-base-command - (replace-regexp-in-string " -i " " -S " counsel-rg-base-command)) - (args (concat - (if all-files-p " -uu") - (unless recursion-p " --maxdepth 1")))) + (let ((args (concat " -S" ; smart-case + (if all-files-p " -uu") + (unless recursion-p " --maxdepth 1")))) (counsel-rg query directory args (format prompt args)))) ('pt) ;; TODO pt search engine (necessary?) (_ (error "No search engine specified"))))) @@ -88,7 +86,7 @@ If ALL-FILES-P, don't respect .gitignore files and search everything." ;;;###autoload (autoload '+ivy:ag "completion/ivy/autoload/evil" nil t) (evil-define-operator +ivy:ag (beg end query &optional all-files-p directory) - "Perform a project file search using the silver search. QUERY is a pcre + "Perform a project file search using the silver searcher. QUERY is a pcre regexp. If omitted, the current selection is used. If no selection is active, the last known search is used.