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)
|
|
|
|
(evil-define-operator +ivy:file-search (beg end search regex-p &optional dir)
|
|
|
|
"Preform a `counsel-rg' search with SEARCH. If SEARCH is nil and in visual
|
|
|
|
mode, use the selection, otherwise activate live ag searching in helm.
|
2017-02-19 18:41:37 -05:00
|
|
|
|
|
|
|
If REGEX-P is non-nil, SEARCH will be treated as a regular expression.
|
|
|
|
DIR specifies the default-directory from which ag is run."
|
|
|
|
:type inclusive :repeat nil
|
|
|
|
(interactive "<r><a><!>")
|
|
|
|
(let ((search (or search
|
|
|
|
(and (evil-visual-state-p)
|
2017-05-06 16:41:17 +02:00
|
|
|
(and beg end (buffer-substring-no-properties beg end)))
|
|
|
|
+ivy--file-last-search)))
|
|
|
|
(setq +ivy--file-last-search search)
|
|
|
|
(counsel-rg search
|
2017-04-11 09:25:04 -04:00
|
|
|
(or dir (doom-project-root))
|
2017-05-06 16:41:17 +02:00
|
|
|
(unless regex-p " -F")
|
|
|
|
(format "File search (%s)" (if regex-p "regex" "literal")))))
|
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)
|
|
|
|
(evil-define-operator +ivy:file-search-cwd (beg end search regex-p)
|
2017-02-19 18:41:37 -05:00
|
|
|
:type inclusive :repeat nil
|
|
|
|
(interactive "<r><a><!>")
|
2017-05-06 16:41:17 +02:00
|
|
|
(+ivy:file-search beg end search regex-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>")
|
|
|
|
(swiper (or search (thing-at-point 'symbol))))
|