2017-06-08 11:47:56 +02:00
|
|
|
;;; completion/ivy/config.el -*- lexical-binding: t; -*-
|
2017-02-13 04:54:12 -05:00
|
|
|
|
2019-03-07 11:07:45 +10:00
|
|
|
(defvar +ivy-buffer-preview nil
|
|
|
|
"If non-nil, preview buffers while switching, à la `counsel-switch-buffer'.
|
|
|
|
|
|
|
|
When nil, don't preview anything.
|
|
|
|
When non-nil, preview non-virtual buffers.
|
|
|
|
When 'everything, also preview virtual buffers")
|
|
|
|
|
2019-04-07 15:54:03 -04:00
|
|
|
(defvar +ivy-buffer-unreal-face 'font-lock-comment-face
|
|
|
|
"The face for unreal buffers in `ivy-switch-to-buffer'.")
|
|
|
|
|
2019-05-20 21:06:06 -04:00
|
|
|
(defvar +ivy-edit-functions nil
|
|
|
|
"A plist mapping ivy/counsel commands to commands that generate an editable
|
|
|
|
results buffer.")
|
|
|
|
|
2017-02-13 21:11:54 -05:00
|
|
|
|
|
|
|
;;
|
2019-04-06 01:31:59 -04:00
|
|
|
;;; Packages
|
2017-02-13 21:11:54 -05:00
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! ivy
|
Backport bits of CLI rewrite
The rewrite for Doom's CLI is taking a while, so I've backported a few
important changes in order to ease the transition and fix a couple bugs
sooner.
Fixes #2802, #2737, #2386
The big highlights are:
- Fix #2802: We now update recipe repos *before* updating/installing any
new packages. No more "Could not find package X in recipe repositories".
- Fix #2737: An edge case where straight couldn't reach a pinned
commit (particularly with agda).
- Doom is now smarter about what option it recommends when straight
prompts you to make a choice.
- Introduces a new init path for Doom. The old way:
- Launch in "minimal" CLI mode in non-interactive sessions
- Launch a "full" interactive mode otherwise.
The new way
- Launch in "minimal" CLI mode *only* for bin/doom
- Launch is a simple mode for non-interactive sessions that still need
access to your interactive config (like async org export/babel).
- Launch a "full" interactive mode otherwise.
This should fix compatibility issues with plugins that use the
async.el library or spawn child Emacs processes to fake
parallelization (like org's async export and babel functionality).
- Your private init.el is now loaded more reliably when running any
bin/doom command. This gives you an opportunity to configure its
settings.
- Added doom-first-{input,buffer,file}-hook hooks, which we use to queue
deferred activation of a number of packages. Users can remove these
modes from these hooks; altogether preventing them from loading,
rather than waiting for them to load to then disable them,
e.g. (after! smartparens (smartparens-global-mode -1)) -> (remove-hook
'doom-first-buffer #'smartparens-global-mode)
Hooks added to doom-first-*-hook variables will be removed once they
run.
This should also indirectly fix #2386, by preventing interactive modes
from running in non-interactive session.
- Added `doom/bump-*` commands to make bumping modules and packages
easier, and `doom/bumpify-*` commands for converting package!
statements into user/repo@sha1hash format for bump commits.
- straight.el is now commit-pinned, like all other packages. We also
more reliably install straight.el by cloning it ourselves, rather than
relying on its bootstrap.el.
This should prevent infinite "straight has diverged from master"
prompts whenever we change branches (though, you might have to put up
with it one more after this update -- see #2937 for workaround).
All the other minor changes:
- Moved core/autoload/cli.el to core/autoload/process.el
- The package manager will log attempts to check out pinned commits
- If package state is incomplete while rebuilding packages, emit a
simpler error message instead of an obscure one!
- Added -u switch to 'doom sync' to make it run 'doom update' afterwards
- Added -p switch to 'doom sync' to make it run 'doom purge' afterwards
- Replace doom-modules function with doom-modules-list
- The `with-plist!` macro was removed, since `cl-destructuring-bind`
already serves that purpose well enough.
- core/autoload/packages.el was moved into core-packages.el
- bin/doom will no longer die if DOOMDIR or DOOMLOCALDIR don't have a
trailing slash
- Introduces doom-debug-variables; a list of variables to toggle on
doom/toggle-debug-mode.
- The sandbox has been updated to reflect the above changes, also:
1. Child instances will no longer inherit the process environment of
the host instance,
2. It will no longer produce an auto-save-list directory in ~/.emacs.d
2020-05-14 15:00:23 -04:00
|
|
|
:hook (doom-first-input . ivy-mode)
|
2019-06-11 18:11:51 +02:00
|
|
|
:init
|
2020-01-06 01:29:22 -05:00
|
|
|
(let ((standard-search-fn
|
|
|
|
(if (featurep! +prescient)
|
|
|
|
#'+ivy-prescient-non-fuzzy
|
|
|
|
#'ivy--regex-plus))
|
|
|
|
(alt-search-fn
|
2020-01-12 03:07:35 -05:00
|
|
|
(if (featurep! +fuzzy)
|
|
|
|
#'ivy--regex-fuzzy
|
|
|
|
;; Ignore order for non-fuzzy searches by default
|
|
|
|
#'ivy--regex-ignore-order)))
|
2020-01-06 01:29:22 -05:00
|
|
|
(setq ivy-re-builders-alist
|
|
|
|
`((counsel-rg . ,standard-search-fn)
|
|
|
|
(swiper . ,standard-search-fn)
|
|
|
|
(swiper-isearch . ,standard-search-fn)
|
|
|
|
(t . ,alt-search-fn))
|
|
|
|
ivy-more-chars-alist
|
|
|
|
'((counsel-rg . 1)
|
|
|
|
(counsel-search . 2)
|
|
|
|
(t . 3))))
|
2019-10-25 20:24:36 -04:00
|
|
|
|
|
|
|
(define-key!
|
|
|
|
[remap switch-to-buffer] #'+ivy/switch-buffer
|
|
|
|
[remap switch-to-buffer-other-window] #'+ivy/switch-buffer-other-window
|
|
|
|
[remap persp-switch-to-buffer] #'+ivy/switch-workspace-buffer
|
|
|
|
[remap evil-show-jumps] #'+ivy/jump-list)
|
2021-04-18 12:41:34 -04:00
|
|
|
|
|
|
|
;; Fix #4886: otherwise our remaps are overwritten
|
|
|
|
(setq ivy-mode-map (make-sparse-keymap))
|
2017-02-22 04:27:23 -05:00
|
|
|
:config
|
2020-08-13 15:47:38 -04:00
|
|
|
;; The default sorter is much to slow and the default for `ivy-sort-max-size'
|
|
|
|
;; is way too big (30,000). Turn it down so big repos affect project
|
|
|
|
;; navigation less.
|
|
|
|
(setq ivy-sort-max-size 7500)
|
|
|
|
|
2019-11-17 17:56:25 -05:00
|
|
|
;; Counsel changes a lot of ivy's state at startup; to control for that, we
|
|
|
|
;; need to load it as early as possible. Some packages (like `ivy-prescient')
|
|
|
|
;; require this.
|
|
|
|
(require 'counsel nil t)
|
|
|
|
|
2019-10-26 04:06:10 -04:00
|
|
|
(setq ivy-height 17
|
2017-02-13 04:54:12 -05:00
|
|
|
ivy-wrap t
|
|
|
|
ivy-fixed-height-minibuffer t
|
2020-12-15 00:10:29 +01:00
|
|
|
ivy-read-action-function #'ivy-hydra-read-action
|
2020-12-13 15:40:29 -05:00
|
|
|
ivy-read-action-format-function #'ivy-read-action-format-columns
|
2017-02-22 04:27:23 -05:00
|
|
|
projectile-completion-system 'ivy
|
2018-01-08 14:41:41 -05:00
|
|
|
;; don't show recent files in switch-buffer
|
|
|
|
ivy-use-virtual-buffers nil
|
|
|
|
;; ...but if that ever changes, show their full path
|
2018-03-23 02:23:57 -04:00
|
|
|
ivy-virtual-abbreviate 'full
|
|
|
|
;; don't quit minibuffer on delete-error
|
2019-12-13 23:00:01 -05:00
|
|
|
ivy-on-del-error-function #'ignore
|
2018-05-14 20:03:36 +02:00
|
|
|
;; enable ability to select prompt (alternative to `ivy-immediate-done')
|
2019-06-11 18:11:51 +02:00
|
|
|
ivy-use-selectable-prompt t)
|
2017-02-13 04:54:12 -05:00
|
|
|
|
2019-10-25 20:24:36 -04:00
|
|
|
;; Highlight each ivy candidate including the following newline, so that it
|
|
|
|
;; extends to the right edge of the window
|
2019-09-20 23:10:53 -04:00
|
|
|
(setf (alist-get 't ivy-format-functions-alist)
|
2020-08-07 23:07:51 -04:00
|
|
|
#'+ivy-format-function-line-or-arrow)
|
2019-09-20 23:10:53 -04:00
|
|
|
|
2019-10-18 17:42:37 -04:00
|
|
|
;; Integrate `ivy' with `better-jumper'; ensure a jump point is registered
|
|
|
|
;; before jumping to new locations with ivy
|
2019-10-25 20:24:36 -04:00
|
|
|
(setf (alist-get 't ivy-hooks-alist)
|
|
|
|
(lambda ()
|
|
|
|
(with-ivy-window
|
|
|
|
(setq +ivy--origin (point-marker)))))
|
2019-05-19 02:13:20 -04:00
|
|
|
|
2019-07-28 14:52:59 +02:00
|
|
|
(add-hook! 'minibuffer-exit-hook
|
2019-07-18 15:27:20 +02:00
|
|
|
(defun +ivy--set-jump-point-maybe-h ()
|
2021-01-18 19:52:46 -05:00
|
|
|
(when (markerp (bound-and-true-p +ivy--origin))
|
|
|
|
(unless (equal (ignore-errors (with-ivy-window (point-marker)))
|
|
|
|
+ivy--origin)
|
|
|
|
(with-current-buffer (marker-buffer +ivy--origin)
|
|
|
|
(better-jumper-set-jump +ivy--origin)))
|
|
|
|
(set-marker +ivy--origin nil))
|
2019-10-25 20:24:36 -04:00
|
|
|
(setq +ivy--origin nil)))
|
2019-05-19 02:13:20 -04:00
|
|
|
|
2018-07-28 12:33:27 +02:00
|
|
|
(after! yasnippet
|
2020-05-15 01:44:53 -04:00
|
|
|
(add-hook 'yas-prompt-functions #'+ivy-yas-prompt-fn))
|
2017-02-22 04:27:23 -05:00
|
|
|
|
2020-12-15 00:28:50 +01:00
|
|
|
(after! ivy-hydra
|
|
|
|
;; Ensure `ivy-dispatching-done' and `hydra-ivy/body' hydras can be
|
|
|
|
;; exited / toggled by the same key binding they were opened
|
|
|
|
(add-to-list 'ivy-dispatching-done-hydra-exit-keys '("C-o" nil))
|
|
|
|
(defhydra+ hydra-ivy () ("M-o" nil)))
|
|
|
|
|
2020-01-01 16:02:08 -05:00
|
|
|
(define-key! ivy-minibuffer-map
|
2020-03-11 22:17:00 -04:00
|
|
|
[remap doom/delete-backward-word] #'ivy-backward-kill-word
|
Backport bits of CLI rewrite
The rewrite for Doom's CLI is taking a while, so I've backported a few
important changes in order to ease the transition and fix a couple bugs
sooner.
Fixes #2802, #2737, #2386
The big highlights are:
- Fix #2802: We now update recipe repos *before* updating/installing any
new packages. No more "Could not find package X in recipe repositories".
- Fix #2737: An edge case where straight couldn't reach a pinned
commit (particularly with agda).
- Doom is now smarter about what option it recommends when straight
prompts you to make a choice.
- Introduces a new init path for Doom. The old way:
- Launch in "minimal" CLI mode in non-interactive sessions
- Launch a "full" interactive mode otherwise.
The new way
- Launch in "minimal" CLI mode *only* for bin/doom
- Launch is a simple mode for non-interactive sessions that still need
access to your interactive config (like async org export/babel).
- Launch a "full" interactive mode otherwise.
This should fix compatibility issues with plugins that use the
async.el library or spawn child Emacs processes to fake
parallelization (like org's async export and babel functionality).
- Your private init.el is now loaded more reliably when running any
bin/doom command. This gives you an opportunity to configure its
settings.
- Added doom-first-{input,buffer,file}-hook hooks, which we use to queue
deferred activation of a number of packages. Users can remove these
modes from these hooks; altogether preventing them from loading,
rather than waiting for them to load to then disable them,
e.g. (after! smartparens (smartparens-global-mode -1)) -> (remove-hook
'doom-first-buffer #'smartparens-global-mode)
Hooks added to doom-first-*-hook variables will be removed once they
run.
This should also indirectly fix #2386, by preventing interactive modes
from running in non-interactive session.
- Added `doom/bump-*` commands to make bumping modules and packages
easier, and `doom/bumpify-*` commands for converting package!
statements into user/repo@sha1hash format for bump commits.
- straight.el is now commit-pinned, like all other packages. We also
more reliably install straight.el by cloning it ourselves, rather than
relying on its bootstrap.el.
This should prevent infinite "straight has diverged from master"
prompts whenever we change branches (though, you might have to put up
with it one more after this update -- see #2937 for workaround).
All the other minor changes:
- Moved core/autoload/cli.el to core/autoload/process.el
- The package manager will log attempts to check out pinned commits
- If package state is incomplete while rebuilding packages, emit a
simpler error message instead of an obscure one!
- Added -u switch to 'doom sync' to make it run 'doom update' afterwards
- Added -p switch to 'doom sync' to make it run 'doom purge' afterwards
- Replace doom-modules function with doom-modules-list
- The `with-plist!` macro was removed, since `cl-destructuring-bind`
already serves that purpose well enough.
- core/autoload/packages.el was moved into core-packages.el
- bin/doom will no longer die if DOOMDIR or DOOMLOCALDIR don't have a
trailing slash
- Introduces doom-debug-variables; a list of variables to toggle on
doom/toggle-debug-mode.
- The sandbox has been updated to reflect the above changes, also:
1. Child instances will no longer inherit the process environment of
the host instance,
2. It will no longer produce an auto-save-list directory in ~/.emacs.d
2020-05-14 15:00:23 -04:00
|
|
|
"C-c C-e" #'+ivy/woccur
|
2020-03-11 22:17:00 -04:00
|
|
|
"C-o" #'ivy-dispatching-done
|
Backport bits of CLI rewrite
The rewrite for Doom's CLI is taking a while, so I've backported a few
important changes in order to ease the transition and fix a couple bugs
sooner.
Fixes #2802, #2737, #2386
The big highlights are:
- Fix #2802: We now update recipe repos *before* updating/installing any
new packages. No more "Could not find package X in recipe repositories".
- Fix #2737: An edge case where straight couldn't reach a pinned
commit (particularly with agda).
- Doom is now smarter about what option it recommends when straight
prompts you to make a choice.
- Introduces a new init path for Doom. The old way:
- Launch in "minimal" CLI mode in non-interactive sessions
- Launch a "full" interactive mode otherwise.
The new way
- Launch in "minimal" CLI mode *only* for bin/doom
- Launch is a simple mode for non-interactive sessions that still need
access to your interactive config (like async org export/babel).
- Launch a "full" interactive mode otherwise.
This should fix compatibility issues with plugins that use the
async.el library or spawn child Emacs processes to fake
parallelization (like org's async export and babel functionality).
- Your private init.el is now loaded more reliably when running any
bin/doom command. This gives you an opportunity to configure its
settings.
- Added doom-first-{input,buffer,file}-hook hooks, which we use to queue
deferred activation of a number of packages. Users can remove these
modes from these hooks; altogether preventing them from loading,
rather than waiting for them to load to then disable them,
e.g. (after! smartparens (smartparens-global-mode -1)) -> (remove-hook
'doom-first-buffer #'smartparens-global-mode)
Hooks added to doom-first-*-hook variables will be removed once they
run.
This should also indirectly fix #2386, by preventing interactive modes
from running in non-interactive session.
- Added `doom/bump-*` commands to make bumping modules and packages
easier, and `doom/bumpify-*` commands for converting package!
statements into user/repo@sha1hash format for bump commits.
- straight.el is now commit-pinned, like all other packages. We also
more reliably install straight.el by cloning it ourselves, rather than
relying on its bootstrap.el.
This should prevent infinite "straight has diverged from master"
prompts whenever we change branches (though, you might have to put up
with it one more after this update -- see #2937 for workaround).
All the other minor changes:
- Moved core/autoload/cli.el to core/autoload/process.el
- The package manager will log attempts to check out pinned commits
- If package state is incomplete while rebuilding packages, emit a
simpler error message instead of an obscure one!
- Added -u switch to 'doom sync' to make it run 'doom update' afterwards
- Added -p switch to 'doom sync' to make it run 'doom purge' afterwards
- Replace doom-modules function with doom-modules-list
- The `with-plist!` macro was removed, since `cl-destructuring-bind`
already serves that purpose well enough.
- core/autoload/packages.el was moved into core-packages.el
- bin/doom will no longer die if DOOMDIR or DOOMLOCALDIR don't have a
trailing slash
- Introduces doom-debug-variables; a list of variables to toggle on
doom/toggle-debug-mode.
- The sandbox has been updated to reflect the above changes, also:
1. Child instances will no longer inherit the process environment of
the host instance,
2. It will no longer produce an auto-save-list directory in ~/.emacs.d
2020-05-14 15:00:23 -04:00
|
|
|
"M-o" #'hydra-ivy/body))
|
2018-01-08 14:41:41 -05:00
|
|
|
|
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! ivy-rich
|
2019-04-25 22:18:17 -04:00
|
|
|
:after ivy
|
2018-09-19 23:34:00 -04:00
|
|
|
:config
|
2019-12-06 17:16:34 -05:00
|
|
|
(setq ivy-rich-parse-remote-buffer nil)
|
|
|
|
|
2019-04-25 22:18:17 -04:00
|
|
|
(when (featurep! +icons)
|
2019-04-26 23:48:49 +10:00
|
|
|
(cl-pushnew '(+ivy-rich-buffer-icon)
|
2019-04-06 01:31:59 -04:00
|
|
|
(cadr (plist-get ivy-rich-display-transformers-list
|
2020-05-26 20:31:09 -04:00
|
|
|
'ivy-switch-buffer))
|
|
|
|
:test #'equal))
|
2019-04-06 01:31:59 -04:00
|
|
|
|
2020-12-01 16:14:49 +01:00
|
|
|
(defun ivy-rich-bookmark-filename-or-empty (candidate)
|
|
|
|
(let ((filename (ivy-rich-bookmark-filename candidate)))
|
|
|
|
(if (not filename) "" filename)))
|
|
|
|
|
2020-05-15 01:44:53 -04:00
|
|
|
;; Enahnce the appearance of a couple counsel commands
|
2019-10-18 17:42:37 -04:00
|
|
|
(plist-put! ivy-rich-display-transformers-list
|
|
|
|
'counsel-describe-variable
|
|
|
|
'(:columns
|
|
|
|
((counsel-describe-variable-transformer (:width 40)) ; the original transformer
|
2020-05-15 01:44:53 -04:00
|
|
|
(+ivy-rich-describe-variable-transformer (:width 50)) ; display variable value
|
2020-04-08 15:29:29 -04:00
|
|
|
(ivy-rich-counsel-variable-docstring (:face font-lock-doc-face))))
|
|
|
|
'counsel-M-x
|
|
|
|
'(:columns
|
|
|
|
((counsel-M-x-transformer (:width 60))
|
|
|
|
(ivy-rich-counsel-function-docstring (:face font-lock-doc-face))))
|
|
|
|
;; Apply switch buffer transformers to `counsel-projectile-switch-to-buffer' as well
|
|
|
|
'counsel-projectile-switch-to-buffer
|
2020-04-29 16:22:01 -07:00
|
|
|
(plist-get ivy-rich-display-transformers-list 'ivy-switch-buffer)
|
|
|
|
'counsel-bookmark
|
|
|
|
'(:columns
|
|
|
|
((ivy-rich-candidate (:width 0.5))
|
2020-12-01 16:14:49 +01:00
|
|
|
(ivy-rich-bookmark-filename-or-empty (:width 60)))))
|
2019-05-14 10:06:36 -04:00
|
|
|
|
2019-04-10 19:22:29 -04:00
|
|
|
;; Remove built-in coloring of buffer list; we do our own
|
|
|
|
(setq ivy-switch-buffer-faces-alist nil)
|
|
|
|
(ivy-set-display-transformer 'internal-complete-buffer nil)
|
|
|
|
|
2019-04-06 01:31:59 -04:00
|
|
|
;; Highlight buffers differently based on whether they're in the same project
|
|
|
|
;; as the current project or not.
|
2020-05-15 01:44:53 -04:00
|
|
|
(when-let* ((plist (plist-get ivy-rich-display-transformers-list 'ivy-switch-buffer))
|
|
|
|
(switch-buffer-alist (assq 'ivy-rich-candidate (plist-get plist :columns))))
|
|
|
|
(setcar switch-buffer-alist '+ivy-rich-buffer-name))
|
2019-04-06 01:31:59 -04:00
|
|
|
|
2021-02-08 11:43:17 +07:00
|
|
|
(ivy-rich-mode +1)
|
|
|
|
(ivy-rich-project-root-cache-mode +1))
|
2019-04-25 22:18:17 -04:00
|
|
|
|
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! all-the-icons-ivy
|
2019-04-25 22:18:17 -04:00
|
|
|
:when (featurep! +icons)
|
|
|
|
:after ivy
|
|
|
|
:config
|
|
|
|
;; `all-the-icons-ivy' is incompatible with ivy-rich's switch-buffer
|
|
|
|
;; modifications, so we disable them and merge them ourselves
|
|
|
|
(setq all-the-icons-ivy-buffer-commands nil)
|
|
|
|
|
|
|
|
(all-the-icons-ivy-setup)
|
|
|
|
(after! counsel-projectile
|
2020-04-08 15:29:29 -04:00
|
|
|
(let ((all-the-icons-ivy-file-commands
|
|
|
|
'(counsel-projectile
|
|
|
|
counsel-projectile-find-file
|
|
|
|
counsel-projectile-find-dir)))
|
2019-04-25 22:18:17 -04:00
|
|
|
(all-the-icons-ivy-setup))))
|
2018-09-19 23:34:00 -04:00
|
|
|
|
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! counsel
|
2019-11-17 17:56:25 -05:00
|
|
|
:defer t
|
2018-01-27 20:57:02 -05:00
|
|
|
:init
|
2019-10-18 17:42:37 -04:00
|
|
|
(define-key!
|
|
|
|
[remap apropos] #'counsel-apropos
|
|
|
|
[remap bookmark-jump] #'counsel-bookmark
|
2020-01-23 02:05:46 -05:00
|
|
|
[remap compile] #'+ivy/compile
|
|
|
|
[remap describe-bindings] #'counsel-descbinds
|
2019-10-18 17:42:37 -04:00
|
|
|
[remap describe-face] #'counsel-faces
|
|
|
|
[remap describe-function] #'counsel-describe-function
|
|
|
|
[remap describe-variable] #'counsel-describe-variable
|
2021-01-31 06:24:25 +07:00
|
|
|
[remap describe-symbol] #'counsel-describe-symbol
|
2020-01-23 02:05:46 -05:00
|
|
|
[remap evil-ex-registers] #'counsel-evil-registers
|
|
|
|
[remap evil-show-marks] #'counsel-mark-ring
|
2019-10-18 17:42:37 -04:00
|
|
|
[remap execute-extended-command] #'counsel-M-x
|
|
|
|
[remap find-file] #'counsel-find-file
|
|
|
|
[remap find-library] #'counsel-find-library
|
|
|
|
[remap imenu] #'counsel-imenu
|
2020-01-23 02:05:46 -05:00
|
|
|
[remap info-lookup-symbol] #'counsel-info-lookup-symbol
|
2019-11-21 14:42:37 -05:00
|
|
|
[remap load-theme] #'counsel-load-theme
|
2019-10-18 17:42:37 -04:00
|
|
|
[remap locate] #'counsel-locate
|
2020-06-04 20:02:46 -04:00
|
|
|
[remap org-goto] #'counsel-org-goto
|
2020-01-23 02:05:46 -05:00
|
|
|
[remap org-set-tags-command] #'counsel-org-tag
|
|
|
|
[remap projectile-compile-project] #'+ivy/project-compile
|
|
|
|
[remap recentf-open-files] #'counsel-recentf
|
|
|
|
[remap set-variable] #'counsel-set-variable
|
|
|
|
[remap swiper] #'counsel-grep-or-swiper
|
2019-10-20 19:00:15 -04:00
|
|
|
[remap unicode-chars-list-chars] #'counsel-unicode-char
|
2020-01-23 02:05:46 -05:00
|
|
|
[remap yank-pop] #'counsel-yank-pop)
|
2017-02-13 21:11:54 -05:00
|
|
|
:config
|
2018-06-18 02:26:05 +02:00
|
|
|
(set-popup-rule! "^\\*ivy-occur" :size 0.35 :ttl 0 :quit nil)
|
2018-01-28 22:24:45 -05:00
|
|
|
|
2019-12-31 00:02:20 -05:00
|
|
|
;; HACK Fix an issue where `counsel-projectile-find-file-action' would try to
|
|
|
|
;; open a candidate in an occur buffer relative to the wrong buffer,
|
|
|
|
;; causing it to fail to find the file we want.
|
|
|
|
(defadvice! +ivy--run-from-ivy-directory-a (orig-fn &rest args)
|
|
|
|
:around #'counsel-projectile-find-file-action
|
|
|
|
(let ((default-directory (ivy-state-directory ivy-last)))
|
|
|
|
(apply orig-fn args)))
|
|
|
|
|
2019-10-18 17:42:37 -04:00
|
|
|
;; Don't use ^ as initial input. Set this here because `counsel' defines more
|
|
|
|
;; of its own, on top of the defaults.
|
|
|
|
(setq ivy-initial-inputs-alist nil)
|
|
|
|
|
2020-06-07 13:58:06 -04:00
|
|
|
;; REVIEW Counsel allows `counsel-rg-base-command' to be a string or list.
|
|
|
|
;; This backwards compatibility complicates things for Doom. Simpler to
|
|
|
|
;; just force it to always be a list.
|
|
|
|
(when (stringp counsel-rg-base-command)
|
|
|
|
(setq counsel-rg-base-command (split-string counsel-rg-base-command)))
|
|
|
|
|
2019-10-18 17:42:37 -04:00
|
|
|
;; Integrate with `helpful'
|
|
|
|
(setq counsel-describe-function-function #'helpful-callable
|
|
|
|
counsel-describe-variable-function #'helpful-variable)
|
|
|
|
|
2021-01-05 19:28:09 -05:00
|
|
|
;; Decorate `doom/help-custom-variable' results the same way as
|
|
|
|
;; `counsel-describe-variable' (adds value and docstring columns).
|
|
|
|
(ivy-configure 'doom/help-custom-variable :parent 'counsel-describe-variable)
|
|
|
|
|
2019-12-20 14:03:35 -05:00
|
|
|
;; Record in jumplist when opening files via counsel-{ag,rg,pt,git-grep}
|
|
|
|
(add-hook 'counsel-grep-post-action-hook #'better-jumper-set-jump)
|
2020-05-08 16:14:47 -04:00
|
|
|
(add-hook 'counsel-grep-post-action-hook #'recenter)
|
2019-12-20 14:03:35 -05:00
|
|
|
(ivy-add-actions
|
2019-12-31 00:02:00 -05:00
|
|
|
'counsel-rg ; also applies to `counsel-rg'
|
2019-12-20 14:03:35 -05:00
|
|
|
'(("O" +ivy-git-grep-other-window-action "open in other window")))
|
|
|
|
|
2019-10-17 01:45:04 -04:00
|
|
|
;; Make `counsel-compile' projectile-aware (if you prefer it over
|
|
|
|
;; `+ivy/compile' and `+ivy/project-compile')
|
|
|
|
(add-to-list 'counsel-compile-root-functions #'projectile-project-root)
|
2019-10-17 01:43:37 -04:00
|
|
|
(after! savehist
|
|
|
|
;; Persist `counsel-compile' history
|
|
|
|
(add-to-list 'savehist-additional-variables 'counsel-compile-history))
|
|
|
|
|
2020-01-12 18:12:01 -05:00
|
|
|
;; `counsel-imenu' -- no sorting for imenu. Sort it by appearance in page.
|
|
|
|
(add-to-list 'ivy-sort-functions-alist '(counsel-imenu))
|
|
|
|
|
2019-12-20 14:03:35 -05:00
|
|
|
;; `counsel-locate'
|
2019-09-23 00:35:57 +09:00
|
|
|
(when IS-MAC
|
2019-12-20 14:03:35 -05:00
|
|
|
;; Use spotlight on mac by default since it doesn't need any additional setup
|
2019-09-23 00:35:57 +09:00
|
|
|
(setq counsel-locate-cmd #'counsel-locate-cmd-mdfind))
|
2017-02-13 04:54:12 -05:00
|
|
|
|
2019-12-20 14:03:35 -05:00
|
|
|
;; `swiper'
|
2019-10-18 17:42:37 -04:00
|
|
|
;; Don't mess with font-locking on the dashboard; it causes breakages
|
|
|
|
(add-to-list 'swiper-font-lock-exclude #'+doom-dashboard-mode)
|
2018-09-08 18:40:11 -04:00
|
|
|
|
2019-12-20 14:03:35 -05:00
|
|
|
;; `counsel-find-file'
|
2019-10-19 17:10:03 -04:00
|
|
|
(setq counsel-find-file-ignore-regexp "\\(?:^[#.]\\)\\|\\(?:[#~]$\\)\\|\\(?:^Icon?\\)")
|
2019-12-31 00:02:00 -05:00
|
|
|
(dolist (fn '(counsel-rg counsel-find-file))
|
|
|
|
(ivy-add-actions
|
|
|
|
fn '(("p" (lambda (path) (with-ivy-window (insert (file-relative-name path default-directory))))
|
|
|
|
"insert relative path")
|
|
|
|
("P" (lambda (path) (with-ivy-window (insert path)))
|
|
|
|
"insert absolute path")
|
|
|
|
("l" (lambda (path) (with-ivy-window (insert (format "[[./%s]]" (file-relative-name path default-directory)))))
|
|
|
|
"insert relative org-link")
|
|
|
|
("L" (lambda (path) (with-ivy-window (insert (format "[[%s]]" path))))
|
|
|
|
"Insert absolute org-link"))))
|
2018-07-04 23:59:18 +08:00
|
|
|
|
2020-01-01 16:49:00 -05:00
|
|
|
(ivy-add-actions 'counsel-file-jump (plist-get ivy--actions-list 'counsel-find-file))
|
|
|
|
|
2019-12-29 19:21:09 -05:00
|
|
|
;; `counsel-search': use normal page for displaying results, so that we see
|
|
|
|
;; custom ddg themes (if one is set).
|
2019-12-20 13:53:54 -05:00
|
|
|
(setf (nth 1 (alist-get 'ddg counsel-search-engines-alist))
|
2019-12-20 14:03:35 -05:00
|
|
|
"https://duckduckgo.com/?q=")
|
|
|
|
|
|
|
|
;; REVIEW Move this somewhere else and perhaps generalize this so both
|
|
|
|
;; ivy/helm users can enjoy it.
|
|
|
|
(defadvice! +ivy--counsel-file-jump-use-fd-rg-a (args)
|
|
|
|
"Change `counsel-file-jump' to use fd or ripgrep, if they are available."
|
|
|
|
:override #'counsel--find-return-list
|
|
|
|
(cl-destructuring-bind (find-program . args)
|
2021-01-08 17:13:46 -05:00
|
|
|
(cond ((when-let (fd (executable-find (or doom-projectile-fd-binary "fd") t))
|
2020-11-16 20:10:26 -05:00
|
|
|
(append (list fd "-H" "--color=never" "--type" "file" "--type" "symlink" "--follow")
|
2020-07-17 01:08:30 -04:00
|
|
|
(if IS-WINDOWS '("--path-separator=/")))))
|
2021-01-08 17:13:46 -05:00
|
|
|
((executable-find "rg" t)
|
2020-11-16 20:10:26 -05:00
|
|
|
(append (list "rg" "--files" "--follow" "--color=never" "--hidden" "-g!.git" "--no-messages")
|
2020-04-24 05:01:27 -04:00
|
|
|
(cl-loop for dir in projectile-globally-ignored-directories
|
2020-05-02 17:41:36 -04:00
|
|
|
collect "--glob"
|
|
|
|
collect (concat "!" dir))
|
2021-01-21 14:10:14 +08:00
|
|
|
(if IS-WINDOWS '("--path-separator=/"))))
|
2019-12-20 14:03:35 -05:00
|
|
|
((cons find-program args)))
|
|
|
|
(unless (listp args)
|
|
|
|
(user-error "`counsel-file-jump-args' is a list now, please customize accordingly."))
|
|
|
|
(counsel--call
|
|
|
|
(cons find-program args)
|
|
|
|
(lambda ()
|
|
|
|
(goto-char (point-min))
|
2020-07-18 19:40:01 -04:00
|
|
|
(let (files)
|
2019-12-20 14:03:35 -05:00
|
|
|
(while (< (point) (point-max))
|
2020-07-18 19:40:01 -04:00
|
|
|
(push (buffer-substring (line-beginning-position) (line-end-position))
|
2020-05-15 01:44:53 -04:00
|
|
|
files)
|
2019-12-20 14:03:35 -05:00
|
|
|
(forward-line 1))
|
|
|
|
(nreverse files)))))))
|
2017-02-13 04:54:12 -05:00
|
|
|
|
2019-04-06 01:31:59 -04:00
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! counsel-projectile
|
2019-07-06 13:31:19 +02:00
|
|
|
:defer t
|
2018-01-27 20:57:02 -05:00
|
|
|
:init
|
2019-10-18 17:42:37 -04:00
|
|
|
(define-key!
|
|
|
|
[remap projectile-find-file] #'+ivy/projectile-find-file
|
|
|
|
[remap projectile-find-dir] #'counsel-projectile-find-dir
|
|
|
|
[remap projectile-switch-to-buffer] #'counsel-projectile-switch-to-buffer
|
|
|
|
[remap projectile-grep] #'counsel-projectile-grep
|
|
|
|
[remap projectile-ag] #'counsel-projectile-ag
|
|
|
|
[remap projectile-switch-project] #'counsel-projectile-switch-project)
|
2018-01-27 20:57:02 -05:00
|
|
|
:config
|
2019-10-18 17:42:37 -04:00
|
|
|
;; A more sensible `counsel-projectile-find-file' that reverts to
|
|
|
|
;; `counsel-find-file' if invoked from $HOME, `counsel-file-jump' if invoked
|
|
|
|
;; from a non-project, `projectile-find-file' if in a big project (more than
|
|
|
|
;; `ivy-sort-max-size' files), or `counsel-projectile-find-file' otherwise.
|
|
|
|
(setf (alist-get 'projectile-find-file counsel-projectile-key-bindings)
|
|
|
|
#'+ivy/projectile-find-file)
|
|
|
|
|
2018-08-04 02:30:26 +02:00
|
|
|
;; no highlighting visited files; slows down the filtering
|
2020-02-22 21:30:21 +01:00
|
|
|
(ivy-set-display-transformer #'counsel-projectile-find-file nil)
|
|
|
|
|
2020-03-27 01:25:30 -04:00
|
|
|
(when (featurep! +prescient)
|
|
|
|
(setq counsel-projectile-sort-files t)))
|
2018-01-27 20:57:02 -05:00
|
|
|
|
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! wgrep
|
2018-05-25 00:46:11 +02:00
|
|
|
:commands wgrep-change-to-wgrep-mode
|
2018-01-14 02:04:30 -05:00
|
|
|
:config (setq wgrep-auto-save-buffer t))
|
2018-05-08 21:47:40 +02:00
|
|
|
|
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! ivy-posframe
|
2019-11-07 12:49:30 -05:00
|
|
|
:when (featurep! +childframe)
|
2019-06-04 00:01:28 +02:00
|
|
|
:hook (ivy-mode . ivy-posframe-mode)
|
2018-05-08 21:47:40 +02:00
|
|
|
:config
|
2018-06-05 11:20:39 +02:00
|
|
|
(setq ivy-fixed-height-minibuffer nil
|
2019-07-10 21:27:12 +02:00
|
|
|
ivy-posframe-border-width 10
|
2018-06-26 01:47:32 +02:00
|
|
|
ivy-posframe-parameters
|
|
|
|
`((min-width . 90)
|
2019-07-10 21:27:12 +02:00
|
|
|
(min-height . ,ivy-height)))
|
2018-05-18 01:21:09 +02:00
|
|
|
|
2018-06-25 14:48:30 +02:00
|
|
|
;; default to posframe display function
|
2019-07-18 15:27:20 +02:00
|
|
|
(setf (alist-get t ivy-posframe-display-functions-alist)
|
|
|
|
#'+ivy-display-at-frame-center-near-bottom-fn)
|
2018-05-08 21:47:40 +02:00
|
|
|
|
2019-12-05 14:56:16 -05:00
|
|
|
;; posframe doesn't work well with async sources (the posframe will
|
|
|
|
;; occasionally stop responding/redrawing), and causes violent resizing of the
|
|
|
|
;; posframe.
|
2019-11-19 13:24:54 +01:00
|
|
|
(dolist (fn '(swiper counsel-rg counsel-grep counsel-git-grep))
|
2019-07-18 15:27:20 +02:00
|
|
|
(setf (alist-get fn ivy-posframe-display-functions-alist)
|
2020-04-25 17:02:47 -04:00
|
|
|
#'ivy-display-function-fallback))
|
|
|
|
|
2020-10-16 22:28:08 -04:00
|
|
|
(add-hook 'doom-after-reload-hook #'posframe-delete-all))
|
2018-05-30 11:25:41 +02:00
|
|
|
|
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! flx
|
2019-10-18 17:42:37 -04:00
|
|
|
:when (featurep! +fuzzy)
|
|
|
|
:unless (featurep! +prescient)
|
2018-08-04 13:47:19 +02:00
|
|
|
:defer t ; is loaded by ivy
|
2019-10-25 20:24:36 -04:00
|
|
|
:init (setq ivy-flx-limit 10000))
|
2018-08-04 13:47:19 +02:00
|
|
|
|
2020-06-18 23:15:33 -03:00
|
|
|
(use-package! ivy-avy
|
|
|
|
:after ivy)
|
2018-08-04 13:47:19 +02:00
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! ivy-prescient
|
2019-05-29 00:01:45 +10:00
|
|
|
:when (featurep! +prescient)
|
2020-04-08 15:29:29 -04:00
|
|
|
:hook (ivy-mode . ivy-prescient-mode)
|
|
|
|
:hook (ivy-prescient-mode . prescient-persist-mode)
|
2020-10-16 23:42:59 -04:00
|
|
|
:commands +ivy-prescient-non-fuzzy
|
2019-05-29 00:01:45 +10:00
|
|
|
:init
|
2019-07-11 17:23:20 +02:00
|
|
|
(setq prescient-filter-method
|
|
|
|
(if (featurep! +fuzzy)
|
|
|
|
'(literal regexp initialism fuzzy)
|
2020-03-03 23:33:53 -05:00
|
|
|
'(literal regexp initialism)))
|
2019-05-29 00:01:45 +10:00
|
|
|
:config
|
2021-03-10 10:46:38 -05:00
|
|
|
;; REVIEW Remove when raxod502/prescient.el#102 is resolved
|
|
|
|
(add-to-list 'ivy-sort-functions-alist '(ivy-resume))
|
2020-03-03 23:33:53 -05:00
|
|
|
(setq ivy-prescient-sort-commands
|
2020-08-26 15:09:52 +08:00
|
|
|
'(:not swiper swiper-isearch ivy-switch-buffer
|
|
|
|
lsp-ivy-workspace-symbol ivy-resume ivy--restore-session
|
2021-04-12 18:29:24 +07:00
|
|
|
counsel-grep counsel-git-grep counsel-rg counsel-ag counsel-ack
|
|
|
|
counsel-fzf counsel-pt counsel-imenu counsel-yank-pop counsel-recentf
|
2021-05-07 21:13:27 -04:00
|
|
|
counsel-buffer-or-recentf counsel-outline counsel-jq)
|
2020-03-03 23:33:53 -05:00
|
|
|
ivy-prescient-retain-classic-highlighting t)
|
2019-05-29 00:01:45 +10:00
|
|
|
(defun +ivy-prescient-non-fuzzy (str)
|
|
|
|
(let ((prescient-filter-method '(literal regexp)))
|
|
|
|
(ivy-prescient-re-builder str)))
|
|
|
|
|
|
|
|
;; NOTE prescient config duplicated with `company'
|
2020-04-08 15:29:29 -04:00
|
|
|
(setq prescient-save-file (concat doom-cache-dir "prescient-save.el")))
|
2019-05-29 00:01:45 +10:00
|
|
|
|
|
|
|
|
2019-10-18 19:46:53 -04:00
|
|
|
;;;###package swiper
|
|
|
|
(setq swiper-action-recenter t)
|
|
|
|
|
|
|
|
|
2019-07-21 23:31:42 +02:00
|
|
|
;;;###package amx
|
|
|
|
(setq amx-save-file (concat doom-cache-dir "amx-items")) ; used by `counsel-M-x'
|