Refactor ivy config
This commit is contained in:
parent
7038a5b66d
commit
d00582ae9c
2 changed files with 20 additions and 12 deletions
|
@ -5,9 +5,13 @@
|
||||||
:init
|
:init
|
||||||
(setq projectile-completion-system 'ivy
|
(setq projectile-completion-system 'ivy
|
||||||
ivy-height 15
|
ivy-height 15
|
||||||
ivy-do-completion-in-region nil)
|
ivy-do-completion-in-region nil
|
||||||
|
ivy-wrap t)
|
||||||
|
|
||||||
:config
|
:config
|
||||||
|
(after! magit
|
||||||
|
(setq magit-completing-read-function 'ivy-completing-read))
|
||||||
|
|
||||||
(ivy-mode +1)
|
(ivy-mode +1)
|
||||||
(map! :map ivy-minibuffer-map
|
(map! :map ivy-minibuffer-map
|
||||||
[escape] 'keyboard-escape-quit
|
[escape] 'keyboard-escape-quit
|
||||||
|
@ -18,23 +22,14 @@
|
||||||
"C-b" 'backward-word
|
"C-b" 'backward-word
|
||||||
"C-f" 'forward-word)
|
"C-f" 'forward-word)
|
||||||
|
|
||||||
|
;;
|
||||||
(require 'counsel)
|
(require 'counsel)
|
||||||
(defun counsel-ag-function (string)
|
|
||||||
"Grep in the current directory for STRING."
|
|
||||||
(if (< (length string) 1)
|
|
||||||
(counsel-more-chars 1)
|
|
||||||
(let ((default-directory counsel--git-grep-dir)
|
|
||||||
(regex (counsel-unquote-regex-parens
|
|
||||||
(setq ivy--old-re
|
|
||||||
(ivy--regex string)))))
|
|
||||||
(counsel--async-command
|
|
||||||
(format counsel-ag-base-command (shell-quote-argument regex)))
|
|
||||||
nil))))
|
|
||||||
|
|
||||||
(add-hook! doom-popup-mode
|
(add-hook! doom-popup-mode
|
||||||
(when (eq major-mode 'ivy-occur-grep-mode)
|
(when (eq major-mode 'ivy-occur-grep-mode)
|
||||||
(ivy-wgrep-change-to-wgrep-mode)))
|
(ivy-wgrep-change-to-wgrep-mode)))
|
||||||
|
|
||||||
|
(advice-add 'counsel-ag-function :override 'doom*counsel-ag-function)
|
||||||
(define-key counsel-ag-map [backtab] 'ivy-occur))
|
(define-key counsel-ag-map [backtab] 'ivy-occur))
|
||||||
|
|
||||||
(use-package counsel-projectile :after projectile)
|
(use-package counsel-projectile :after projectile)
|
||||||
|
|
|
@ -59,5 +59,18 @@ DIR specifies the default-directory from which ag is run."
|
||||||
(interactive "<r><a><!>")
|
(interactive "<r><a><!>")
|
||||||
(doom:ivy-ag-search beg end search regex-p default-directory))
|
(doom:ivy-ag-search beg end search regex-p default-directory))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun doom*counsel-ag-function (string)
|
||||||
|
"Advice to get rid of the character limit from `counsel-ag-function', which
|
||||||
|
interferes with my custom :ag ex command `doom:ivy-ag-search'."
|
||||||
|
(if (< (length string) 1)
|
||||||
|
(counsel-more-chars 1)
|
||||||
|
(let ((default-directory counsel--git-grep-dir)
|
||||||
|
(regex (counsel-unquote-regex-parens
|
||||||
|
(setq ivy--old-re (ivy--regex string)))))
|
||||||
|
(counsel--async-command
|
||||||
|
(format counsel-ag-base-command (shell-quote-argument regex)))
|
||||||
|
nil)))
|
||||||
|
|
||||||
(provide 'defuns-ivy)
|
(provide 'defuns-ivy)
|
||||||
;;; defuns-ivy.el ends here
|
;;; defuns-ivy.el ends here
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue