completion/ivy: switch from ag to ripgrep

This commit is contained in:
Henrik Lissner 2017-05-06 16:41:17 +02:00
parent 8600d2e8d2
commit 434a5efeda
5 changed files with 75 additions and 43 deletions

View file

@ -1,11 +1,11 @@
;;; completion/ivy/autoload/evil.el
(defvar +ivy--ag-last-search nil)
(defvar +ivy--file-last-search nil)
;;;###autoload (autoload '+ivy:ag-search "completion/ivy/autoload/evil" nil t)
(evil-define-operator +ivy:ag-search (beg end search regex-p &optional dir)
"Preform a counsel search with SEARCH. If SEARCH is nil and in visual mode,
use the selection, otherwise activate live ag searching in helm.
;;;###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.
If REGEX-P is non-nil, SEARCH will be treated as a regular expression.
DIR specifies the default-directory from which ag is run."
@ -13,20 +13,19 @@ DIR specifies the default-directory from which ag is run."
(interactive "<r><a><!>")
(let ((search (or search
(and (evil-visual-state-p)
(and beg end
(let ((str (buffer-substring-no-properties beg end)))
(if regex-p (rxt-quote-pcre str) str))))
+ivy--ag-last-search)))
(setq +ivy--ag-last-search search)
(counsel-ag (if regex-p search (regexp-quote search))
(and beg end (buffer-substring-no-properties beg end)))
+ivy--file-last-search)))
(setq +ivy--file-last-search search)
(counsel-rg search
(or dir (doom-project-root))
(concat "--nocolor --nogroup" (if regex-p " -Q")))))
(unless regex-p " -F")
(format "File search (%s)" (if regex-p "regex" "literal")))))
;;;###autoload (autoload '+ivy:ag-search-cwd "completion/ivy/autoload/evil" nil t)
(evil-define-operator +ivy:ag-search-cwd (beg end search regex-p)
;;;###autoload (autoload '+ivy:file-search-cwd "completion/ivy/autoload/evil" nil t)
(evil-define-operator +ivy:file-search-cwd (beg end search regex-p)
:type inclusive :repeat nil
(interactive "<r><a><!>")
(+ivy:ag-search beg end search regex-p default-directory))
(+ivy:file-search beg end search regex-p default-directory))
;;;###autoload (autoload '+ivy:swiper "completion/ivy/autoload/evil" nil t)
(evil-define-command +ivy:swiper (&optional search)