completion/ivy: add grep/git-grep integration to evil+ivy (:grep/:grepc[wd])
This commit is contained in:
parent
6f1b96bc9a
commit
20d97ffbaa
2 changed files with 31 additions and 0 deletions
|
@ -49,6 +49,16 @@
|
||||||
(setq +ivy--file-last-search query)
|
(setq +ivy--file-last-search query)
|
||||||
(require 'counsel)
|
(require 'counsel)
|
||||||
(pcase engine
|
(pcase engine
|
||||||
|
('grep
|
||||||
|
(let ((args (if recursion-p " -r"))
|
||||||
|
(counsel-projectile-grep-initial-input query))
|
||||||
|
(if all-files-p
|
||||||
|
(cl-letf (((symbol-function #'projectile-ignored-directories-rel)
|
||||||
|
(symbol-function #'ignore))
|
||||||
|
((symbol-function #'projectile-ignored-files-rel)
|
||||||
|
(symbol-function #'ignore)))
|
||||||
|
(counsel-projectile-grep args))
|
||||||
|
(counsel-projectile-grep args))))
|
||||||
('ag
|
('ag
|
||||||
(let ((args (concat
|
(let ((args (concat
|
||||||
(if all-files-p " -a")
|
(if all-files-p " -a")
|
||||||
|
@ -65,6 +75,17 @@
|
||||||
('pt) ;; TODO pt search engine (necessary?)
|
('pt) ;; TODO pt search engine (necessary?)
|
||||||
(_ (error "No search engine specified")))))
|
(_ (error "No search engine specified")))))
|
||||||
|
|
||||||
|
;;;###autoload (autoload '+ivy:grep "completion/ivy/autoload/evil" nil t)
|
||||||
|
(evil-define-operator +ivy:grep (beg end query &optional all-files-p directory)
|
||||||
|
"Perform a project file search using grep (or git-grep in git repos). QUERY is
|
||||||
|
a grep regexp. If omitted, the current selection is used. If no selection is
|
||||||
|
active, the last known search is used.
|
||||||
|
|
||||||
|
If ALL-FILES-P, don't respect .gitignore files and search everything."
|
||||||
|
(interactive "<r><a><!>")
|
||||||
|
(let ((+ivy--file-search-all-files-p all-files-p))
|
||||||
|
(+ivy--file-search 'grep beg end query directory)))
|
||||||
|
|
||||||
;;;###autoload (autoload '+ivy:ag "completion/ivy/autoload/evil" nil t)
|
;;;###autoload (autoload '+ivy:ag "completion/ivy/autoload/evil" nil t)
|
||||||
(evil-define-operator +ivy:ag (beg end query &optional all-files-p directory)
|
(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 search. QUERY is a pcre
|
||||||
|
@ -90,6 +111,14 @@ NOTE: ripgrep doesn't support multiline searches (yet)."
|
||||||
(+ivy--file-search 'rg beg end query directory)))
|
(+ivy--file-search 'rg beg end query directory)))
|
||||||
|
|
||||||
|
|
||||||
|
;;;###autoload (autoload '+ivy:ag-cwd "completion/ivy/autoload/evil" nil t)
|
||||||
|
(evil-define-operator +ivy:grep-cwd (beg end query &optional bang)
|
||||||
|
"The same as :git, but searches the current directory. If BANG, don't recurse
|
||||||
|
into sub-directories."
|
||||||
|
(interactive "<r><a><!>")
|
||||||
|
(let ((+ivy--file-search-recursion-p (not bang)))
|
||||||
|
(+ivy:grep beg end query t default-directory)))
|
||||||
|
|
||||||
;;;###autoload (autoload '+ivy:ag-cwd "completion/ivy/autoload/evil" nil t)
|
;;;###autoload (autoload '+ivy:ag-cwd "completion/ivy/autoload/evil" nil t)
|
||||||
(evil-define-operator +ivy:ag-cwd (beg end query &optional bang)
|
(evil-define-operator +ivy:ag-cwd (beg end query &optional bang)
|
||||||
"The same as :ag, but searches the current directory. If BANG, don't recurse
|
"The same as :ag, but searches the current directory. If BANG, don't recurse
|
||||||
|
|
|
@ -78,6 +78,8 @@
|
||||||
(ex! "agc[wd]" #'+ivy:ag-cwd)
|
(ex! "agc[wd]" #'+ivy:ag-cwd)
|
||||||
(ex! "rg" #'+ivy:rg)
|
(ex! "rg" #'+ivy:rg)
|
||||||
(ex! "rgc[wd]" #'+ivy:rg-cwd)
|
(ex! "rgc[wd]" #'+ivy:rg-cwd)
|
||||||
|
(ex! "grep" #'+ivy:grep)
|
||||||
|
(ex! "grepc[wd]" #'+ivy:grep-cwd)
|
||||||
(ex! "sw[iper]" #'+ivy:swiper)
|
(ex! "sw[iper]" #'+ivy:swiper)
|
||||||
(ex! "todo" #'+ivy:todo))
|
(ex! "todo" #'+ivy:todo))
|
||||||
((featurep! :completion helm)
|
((featurep! :completion helm)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue