Improve v2.0 compatibility for modules/completion/ivy
This commit is contained in:
parent
9173d79eb8
commit
54d58c358e
2 changed files with 57 additions and 46 deletions
|
@ -66,46 +66,6 @@ all open buffers."
|
|||
(string-match-p "\\`[\n[:blank:]]+\\'" it)))
|
||||
(cl-remove-duplicates kill-ring :test 'equal))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +ivy/recentf ()
|
||||
"Find a file on `recentf-list'."
|
||||
(interactive)
|
||||
(while (doom-popup-p)
|
||||
(doom/popup-close))
|
||||
(call-interactively 'counsel-recentf))
|
||||
|
||||
;;;###autoload (autoload '+ivy:ag-search "completion/ivy/autoload" nil t)
|
||||
;;;###autoload (autoload '+ivy:ag-search-cwd "completion/ivy/autoload" nil t)
|
||||
;;;###autoload (autoload '+ivy:swiper "completion/ivy/autoload" nil t)
|
||||
(@after evil
|
||||
(defvar doom-ivy-ag-last-search nil)
|
||||
|
||||
(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.
|
||||
|
||||
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)
|
||||
(and beg end (rxt-quote-pcre (buffer-substring-no-properties beg end))))
|
||||
doom-ivy-ag-last-search)))
|
||||
(setq doom-ivy-ag-last-search search)
|
||||
(counsel-ag search (or dir (f-slash (doom-project-root)))
|
||||
(concat "--nocolor --nogroup" (if regex-p " -Q")))))
|
||||
|
||||
(evil-define-operator +ivy:ag-search-cwd (beg end search regex-p)
|
||||
:type inclusive :repeat nil
|
||||
(interactive "<r><a><!>")
|
||||
(+ivy:ag-search beg end search regex-p default-directory))
|
||||
|
||||
(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)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +ivy/tasks ()
|
||||
(interactive)
|
||||
|
@ -140,6 +100,40 @@ interferes with my custom :ag ex command `+ivy:ag-search'."
|
|||
(require 'wgrep)
|
||||
(call-interactively 'ivy-occur))
|
||||
|
||||
(provide 'completion/ivy/autoload)
|
||||
;;; completion/ivy/autoload.el ends here
|
||||
;;;###autoload
|
||||
(defun +ivy-yas-prompt (prompt choices &optional display-fn)
|
||||
(yas-completing-prompt prompt choices display-fn #'ivy-completing-read))
|
||||
|
||||
|
||||
;;;###autoload (autoload '+ivy:ag-search "completion/ivy/autoload" nil t)
|
||||
;;;###autoload (autoload '+ivy:ag-search-cwd "completion/ivy/autoload" nil t)
|
||||
;;;###autoload (autoload '+ivy:swiper "completion/ivy/autoload" nil t)
|
||||
(@after evil
|
||||
(defvar +ivy--ag-last-search nil)
|
||||
|
||||
(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.
|
||||
|
||||
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)
|
||||
(and beg end (rxt-quote-pcre (buffer-substring-no-properties beg end))))
|
||||
+ivy--ag-last-search)))
|
||||
(setq +ivy--ag-last-search search)
|
||||
(counsel-ag search (or dir (f-slash (doom-project-root)))
|
||||
(concat "--nocolor --nogroup" (if regex-p " -Q")))))
|
||||
|
||||
(evil-define-operator +ivy:ag-search-cwd (beg end search regex-p)
|
||||
:type inclusive :repeat nil
|
||||
(interactive "<r><a><!>")
|
||||
(+ivy:ag-search beg end search regex-p default-directory))
|
||||
|
||||
(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)))))
|
||||
|
||||
|
|
|
@ -8,6 +8,22 @@
|
|||
(setq ivy-exit 'done)
|
||||
(exit-minibuffer)))
|
||||
|
||||
(@map [remap find-file] 'counsel-find-file
|
||||
[remap switch-to-buffer] 'ivy-switch-buffer
|
||||
[remap projectile-switch-to-buffer] '+ivy/switch-project-buffer
|
||||
[remap recentf] 'counsel-recentf
|
||||
[remap imenu] 'counsel-imenu
|
||||
[remap bookmark-jump] 'counsel-bookmark
|
||||
[remap projectile-switch-project] 'counsel-projectile-switch-project
|
||||
[remap projectile-find-file] 'counsel-projectile-find-file
|
||||
[remap imenu-anywhere] 'ivy-imenu-anywhere
|
||||
[remap execute-extended-command] 'counsel-M-x)
|
||||
|
||||
|
||||
;;
|
||||
;; Packages
|
||||
;;
|
||||
|
||||
(@def-package ivy :demand t
|
||||
:init
|
||||
(setq ivy-height 14
|
||||
|
@ -17,6 +33,9 @@
|
|||
ivy-format-function 'ivy-format-function-line) ;; highlight til EOL
|
||||
|
||||
:config
|
||||
(setq projectile-completion-system 'ivy
|
||||
smex-completion-method 'ivy)
|
||||
|
||||
(@map :map ivy-mode-map
|
||||
[remap ivy-switch-buffer] '+ivy/switch-buffer
|
||||
[remap projectile-switch-to-buffer] '+ivy/switch-project-buffer
|
||||
|
@ -36,18 +55,16 @@
|
|||
(advice-add 'ivy-read :after 'doom|redisplay)
|
||||
|
||||
(@after magit (setq magit-completing-read-function 'ivy-completing-read))
|
||||
(@after smex (setq smex-completion-method 'ivy))
|
||||
(@after yasnippet (push 'doom-yas-ivy-prompt yas-prompt-functions))
|
||||
(@after yasnippet (push '+ivy-yas-prompt yas-prompt-functions))
|
||||
|
||||
(ivy-mode +1))
|
||||
|
||||
|
||||
(@def-package counsel
|
||||
:after ivy
|
||||
:init
|
||||
:config
|
||||
(setq counsel-find-file-ignore-regexp "\\(?:^[#.]\\)\\|\\(?:[#~]$\\)\\|\\(?:^Icon?\\)")
|
||||
|
||||
:config
|
||||
(require 'counsel-projectile)
|
||||
|
||||
(@def-counsel-action ag-open-in-other-window
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue