2017-06-09 13:36:58 +02:00
|
|
|
;;; completion/helm/autoload/evil.el -*- lexical-binding: t; -*-
|
2017-11-04 22:11:55 +01:00
|
|
|
;;;###if (featurep! :feature evil)
|
2017-06-09 13:36:58 +02:00
|
|
|
|
|
|
|
;;;###autoload (autoload '+helm:swoop "completion/helm/autoload/evil" nil t)
|
|
|
|
(evil-define-command +helm:swoop (&optional search bang)
|
|
|
|
"Invoke `swoop' with SEARCH. If BANG, do multiline search."
|
|
|
|
(interactive "<a><!>")
|
|
|
|
(helm-swoop :$query search :$multiline bang))
|
|
|
|
|
2017-12-07 21:43:31 -05:00
|
|
|
(defun +helm--file-search (beg end query &optional directory options)
|
2017-06-09 13:36:58 +02:00
|
|
|
(require 'helm-ag)
|
|
|
|
(helm-ag--init-state)
|
|
|
|
(let ((helm-ag--default-directory (or directory (doom-project-root)))
|
2017-12-07 21:43:31 -05:00
|
|
|
(query (or query
|
|
|
|
(if (evil-visual-state-p)
|
|
|
|
(and beg end
|
|
|
|
(> (abs (- end beg)) 1)
|
|
|
|
(rxt-quote-pcre (buffer-substring-no-properties beg end)))
|
|
|
|
+helm--file-last-query)
|
|
|
|
+helm--file-last-query))
|
|
|
|
(helm-ag-command-option (concat helm-ag-command-option " " (string-join options " "))))
|
|
|
|
(setq helm-ag--last-query query)
|
2017-06-09 13:36:58 +02:00
|
|
|
(helm-attrset 'search-this-file nil helm-ag-source)
|
|
|
|
(helm-attrset 'name (helm-ag--helm-header helm-ag--default-directory) helm-ag-source)
|
|
|
|
(helm :sources '(helm-ag-source)
|
|
|
|
:input query
|
|
|
|
:buffer "*helm-ag*"
|
|
|
|
:keymap helm-ag-map
|
|
|
|
:history 'helm-ag--helm-history)))
|
|
|
|
|
2017-12-07 21:43:31 -05:00
|
|
|
(defvar +helm--file-last-search nil)
|
|
|
|
;;;###autoload (autoload '+helm:ag "completion/helm/autoload/evil" nil t)
|
|
|
|
(evil-define-command +helm:ag (beg end query &optional bang)
|
|
|
|
"TODO"
|
|
|
|
(interactive "<r><a><!>")
|
|
|
|
(+helm--file-search beg end query nil
|
|
|
|
(if bang (list "-a" "--hidden"))))
|
|
|
|
|
2017-06-09 13:36:58 +02:00
|
|
|
;;;###autoload (autoload '+helm:ag-cwd "completion/helm/autoload/evil" nil t)
|
2017-12-07 21:43:31 -05:00
|
|
|
(evil-define-command +helm:ag-cwd (beg end query &optional bang)
|
2017-06-09 13:36:58 +02:00
|
|
|
"TODO"
|
|
|
|
(interactive "<r><a><!>")
|
2017-12-07 21:43:31 -05:00
|
|
|
(+helm--file-search beg end query default-directory
|
|
|
|
(list "-n" (if bang "-a"))))
|
2017-06-09 13:36:58 +02:00
|
|
|
|
2017-12-07 21:43:31 -05:00
|
|
|
;;;###autoload (autoload '+helm:rg "completion/helm/autoload/evil" nil t)
|
|
|
|
(evil-define-command +helm:rg (beg end query &optional bang)
|
|
|
|
"TODO"
|
|
|
|
(interactive "<r><a><!>")
|
|
|
|
(let ((helm-ag-base-command "rg --no-heading"))
|
|
|
|
(+helm--file-search beg end query nil
|
|
|
|
(if bang (list "-uu")))))
|
|
|
|
|
|
|
|
;;;###autoload (autoload '+helm:rg-cwd "completion/helm/autoload/evil" nil t)
|
|
|
|
(evil-define-command +helm:rg-cwd (beg end query &optional bang)
|
|
|
|
"TODO"
|
|
|
|
(interactive "<r><a><!>")
|
|
|
|
(let ((helm-ag-base-command "rg --no-heading --maxdepth 1"))
|
|
|
|
(+helm--file-search beg end query default-directory
|
|
|
|
(if bang (list "-uu")))))
|
2018-05-31 16:16:24 +02:00
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun +helm--set-prompt-display (pos)
|
|
|
|
"TODO"
|
|
|
|
(let (beg state region-active m)
|
|
|
|
(with-selected-window (minibuffer-window)
|
|
|
|
(setq beg (save-excursion (vertical-motion 0 (helm-window)) (point))
|
|
|
|
state evil-state
|
|
|
|
region-active (region-active-p)
|
|
|
|
m (mark t)))
|
|
|
|
(when region-active
|
|
|
|
(setq m (- m beg))
|
|
|
|
;; Increment pos to handle the space before prompt (i.e `pref').
|
|
|
|
(put-text-property (1+ (min m pos)) (+ 2 (max m pos))
|
|
|
|
'face
|
|
|
|
(list :background (face-background 'region))
|
|
|
|
header-line-format))
|
|
|
|
(put-text-property
|
|
|
|
;; Increment pos to handle the space before prompt (i.e `pref').
|
|
|
|
(+ 1 pos) (+ 2 pos)
|
|
|
|
'face
|
|
|
|
(if (eq state 'insert)
|
|
|
|
'underline
|
|
|
|
;; Don't just use 'cursor, this can hide the current character.
|
|
|
|
(list :inverse-video t
|
|
|
|
:foreground (face-background 'cursor)
|
|
|
|
:background (face-background 'default)))
|
|
|
|
header-line-format)))
|