completion/ivy: change +ivy:file-search
+ Removed literal search + Only escapes inserted selection + BANG now means: don't respect .gitignore + rg: use smart-case (-S) instead of case insensitivity (-i)
This commit is contained in:
parent
f05819c85f
commit
57a74b1761
2 changed files with 21 additions and 17 deletions
3
TODO.org
3
TODO.org
|
@ -95,10 +95,11 @@
|
||||||
+ [ ] Fix invisible buffer-info in modeline for terminal Emacs
|
+ [ ] Fix invisible buffer-info in modeline for terminal Emacs
|
||||||
+ [ ] tools/upload: add ~+upload/open-remote-file~ command to open current file on the remote (with TRAMP)
|
+ [ ] tools/upload: add ~+upload/open-remote-file~ command to open current file on the remote (with TRAMP)
|
||||||
|
|
||||||
** 2.0.2 [57/60]
|
** 2.0.2 [58/61]
|
||||||
+ [ ] Update screenshots
|
+ [ ] Update screenshots
|
||||||
+ [ ] send-to-REPL workflow: does it still work? (see ~:repl~ & ~+eval/repl-send-region~)
|
+ [ ] send-to-REPL workflow: does it still work? (see ~:repl~ & ~+eval/repl-send-region~)
|
||||||
+ [ ] Fix ~0/0~ displaying in modeline (caused by leftover anzu state)
|
+ [ ] Fix ~0/0~ displaying in modeline (caused by leftover anzu state)
|
||||||
|
+ [X] completion/ivy: fix ~+ivy:find-file~ -- loss of functionality with coerced literal searches (better to escape regex rather than pass -F to rg)
|
||||||
+ [X] completion/ivy: refactor ~def-counsel-action!~ +into a setting (~def-setting!~)+
|
+ [X] completion/ivy: refactor ~def-counsel-action!~ +into a setting (~def-setting!~)+
|
||||||
Refactored into ~ivy-do-action!~ macro instead
|
Refactored into ~ivy-do-action!~ macro instead
|
||||||
+ [X] completion/ivy: refactor ag-open-in-other-window (messy/hackish)
|
+ [X] completion/ivy: refactor ag-open-in-other-window (messy/hackish)
|
||||||
|
|
|
@ -3,37 +3,40 @@
|
||||||
(defvar +ivy--file-last-search nil)
|
(defvar +ivy--file-last-search nil)
|
||||||
|
|
||||||
;;;###autoload (autoload '+ivy:file-search "completion/ivy/autoload/evil" nil t)
|
;;;###autoload (autoload '+ivy:file-search "completion/ivy/autoload/evil" nil t)
|
||||||
(evil-define-operator +ivy:file-search (beg end search regex-p &optional dir)
|
(evil-define-operator +ivy:file-search (beg end query all-files-p &optional dir)
|
||||||
"Preform a `counsel-rg' search with SEARCH. If SEARCH is nil and in visual
|
"Preform a `counsel-rg' search with QUERY. If QUERY is nil and in visual mode,
|
||||||
mode, use the selection, otherwise activate live ag searching in helm.
|
use the selection, otherwise activate live rg searching in ivy.
|
||||||
|
|
||||||
If REGEX-P is non-nil, SEARCH will be treated as a regular expression.
|
If ALL-FILES-P is non-nil, don't respect .gitignore files and search everything.
|
||||||
DIR specifies the default-directory from which ag is run.
|
|
||||||
|
|
||||||
If there is no selection and SEARCH is empty, then relaunch the previous search
|
If there is no selection and QUERY is empty, then relaunch the previous search
|
||||||
session."
|
session."
|
||||||
:type inclusive :repeat nil
|
:type inclusive :repeat nil
|
||||||
(interactive "<r><a><!>")
|
(interactive "<r><a><!>")
|
||||||
(let ((search (or search
|
(let ((query (or query
|
||||||
(and (evil-visual-state-p)
|
(and (evil-visual-state-p)
|
||||||
(and beg end (buffer-substring-no-properties beg end)))
|
(and beg end
|
||||||
+ivy--file-last-search)))
|
(rxt-quote-pcre (buffer-substring-no-properties beg end))))
|
||||||
(setq +ivy--file-last-search search)
|
+ivy--file-last-search))
|
||||||
(counsel-rg 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
|
||||||
(or dir (doom-project-root))
|
(or dir (doom-project-root))
|
||||||
(unless regex-p " -F")
|
(when all-files-p " -u")
|
||||||
(format "File search (%s)" (if regex-p "regex" "literal")))))
|
(format "File search%s" (if all-files-p " (all)" "")))))
|
||||||
|
|
||||||
;;;###autoload (autoload '+ivy:file-search-cwd "completion/ivy/autoload/evil" nil t)
|
;;;###autoload (autoload '+ivy:file-search-cwd "completion/ivy/autoload/evil" nil t)
|
||||||
(evil-define-operator +ivy:file-search-cwd (beg end search regex-p)
|
(evil-define-operator +ivy:file-search-cwd (beg end search all-files-p)
|
||||||
"Perform a `counsel-rg' search for SEARCH (or the current selection) in
|
"Perform a `counsel-rg' search for SEARCH (or the current selection) in
|
||||||
`default-directory'."
|
`default-directory'."
|
||||||
:type inclusive :repeat nil
|
:type inclusive :repeat nil
|
||||||
(interactive "<r><a><!>")
|
(interactive "<r><a><!>")
|
||||||
(+ivy:file-search beg end search regex-p default-directory))
|
(+ivy:file-search beg end search all-files-p default-directory))
|
||||||
|
|
||||||
;;;###autoload (autoload '+ivy:swiper "completion/ivy/autoload/evil" nil t)
|
;;;###autoload (autoload '+ivy:swiper "completion/ivy/autoload/evil" nil t)
|
||||||
(evil-define-command +ivy:swiper (&optional search)
|
(evil-define-command +ivy:swiper (&optional search)
|
||||||
"Invoke `swiper' with SEARCH, otherwise with the symbol at point."
|
"Invoke `swiper' with SEARCH, otherwise with the symbol at point."
|
||||||
(interactive "<a>")
|
(interactive "<a>")
|
||||||
(swiper (or search (thing-at-point 'symbol))))
|
(swiper search))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue