2017-02-19 18:41:37 -05:00
|
|
|
;;; completion/ivy/autoload/evil.el
|
|
|
|
|
2017-05-06 16:41:17 +02:00
|
|
|
(defvar +ivy--file-last-search nil)
|
2017-02-19 18:41:37 -05:00
|
|
|
|
2017-05-06 16:41:17 +02:00
|
|
|
;;;###autoload (autoload '+ivy:file-search "completion/ivy/autoload/evil" nil t)
|
2017-05-10 05:21:53 +02:00
|
|
|
(evil-define-operator +ivy:file-search (beg end query all-files-p &optional dir)
|
|
|
|
"Preform a `counsel-rg' search with QUERY. If QUERY is nil and in visual mode,
|
|
|
|
use the selection, otherwise activate live rg searching in ivy.
|
2017-02-19 18:41:37 -05:00
|
|
|
|
2017-05-10 05:21:53 +02:00
|
|
|
If ALL-FILES-P is non-nil, don't respect .gitignore files and search everything.
|
2017-05-06 22:55:41 +02:00
|
|
|
|
2017-05-10 05:21:53 +02:00
|
|
|
If there is no selection and QUERY is empty, then relaunch the previous search
|
2017-05-06 22:55:41 +02:00
|
|
|
session."
|
2017-02-19 18:41:37 -05:00
|
|
|
:type inclusive :repeat nil
|
|
|
|
(interactive "<r><a><!>")
|
2017-05-10 05:21:53 +02:00
|
|
|
(let ((query (or query
|
2017-02-19 18:41:37 -05:00
|
|
|
(and (evil-visual-state-p)
|
2017-05-10 05:21:53 +02:00
|
|
|
(and beg end
|
|
|
|
(rxt-quote-pcre (buffer-substring-no-properties beg end))))
|
|
|
|
+ivy--file-last-search))
|
|
|
|
;; smart-case instead of case-insensitive flag
|
|
|
|
(counsel-rg-base-command
|
|
|
|
(replace-regexp-in-string " -i " " -S " counsel-rg-base-command)))
|
|
|
|
(setq +ivy--file-last-search query)
|
|
|
|
(counsel-rg query
|
2017-04-11 09:25:04 -04:00
|
|
|
(or dir (doom-project-root))
|
2017-05-10 05:21:53 +02:00
|
|
|
(when all-files-p " -u")
|
|
|
|
(format "File search%s" (if all-files-p " (all)" "")))))
|
2017-02-19 18:41:37 -05:00
|
|
|
|
2017-05-06 16:41:17 +02:00
|
|
|
;;;###autoload (autoload '+ivy:file-search-cwd "completion/ivy/autoload/evil" nil t)
|
2017-05-10 05:21:53 +02:00
|
|
|
(evil-define-operator +ivy:file-search-cwd (beg end search all-files-p)
|
2017-05-06 22:55:41 +02:00
|
|
|
"Perform a `counsel-rg' search for SEARCH (or the current selection) in
|
|
|
|
`default-directory'."
|
2017-02-19 18:41:37 -05:00
|
|
|
:type inclusive :repeat nil
|
|
|
|
(interactive "<r><a><!>")
|
2017-05-10 05:21:53 +02:00
|
|
|
(+ivy:file-search beg end search all-files-p default-directory))
|
2017-02-19 18:41:37 -05:00
|
|
|
|
|
|
|
;;;###autoload (autoload '+ivy:swiper "completion/ivy/autoload/evil" nil t)
|
|
|
|
(evil-define-command +ivy:swiper (&optional search)
|
|
|
|
"Invoke `swiper' with SEARCH, otherwise with the symbol at point."
|
|
|
|
(interactive "<a>")
|
2017-05-10 05:21:53 +02:00
|
|
|
(swiper search))
|