2017-06-08 11:47:56 +02:00
|
|
|
;;; completion/ivy/config.el -*- lexical-binding: t; -*-
|
2017-02-13 04:54:12 -05:00
|
|
|
|
2017-08-21 21:54:04 +02:00
|
|
|
(defvar +ivy-buffer-icons nil
|
|
|
|
"If non-nil, show buffer mode icons in `ivy-switch-buffer' and the like.")
|
|
|
|
|
2017-06-08 11:47:56 +02:00
|
|
|
(defvar +ivy-task-tags
|
|
|
|
'(("TODO" . warning)
|
|
|
|
("FIXME" . error))
|
2017-05-10 06:13:14 +02:00
|
|
|
"An alist of tags for `+ivy/tasks' to include in its search, whose CDR is the
|
|
|
|
face to render it with.")
|
|
|
|
|
2017-05-10 08:38:32 +02:00
|
|
|
(defmacro +ivy-do-action! (action)
|
2017-09-15 14:35:18 +02:00
|
|
|
"Returns an interactive lambda that sets the current ivy action and
|
|
|
|
immediately runs it on the current candidate (ending the ivy session)."
|
2017-05-10 05:20:54 +02:00
|
|
|
`(lambda ()
|
2017-02-13 04:54:12 -05:00
|
|
|
(interactive)
|
2017-05-10 05:20:54 +02:00
|
|
|
(ivy-set-action ,action)
|
2017-02-13 04:54:12 -05:00
|
|
|
(setq ivy-exit 'done)
|
|
|
|
(exit-minibuffer)))
|
|
|
|
|
2017-02-13 21:11:54 -05:00
|
|
|
|
|
|
|
;;
|
|
|
|
;; Packages
|
|
|
|
;;
|
|
|
|
|
2017-06-08 11:47:56 +02:00
|
|
|
(def-package! ivy
|
2017-09-04 02:38:29 +02:00
|
|
|
:init
|
2018-01-07 00:03:34 -05:00
|
|
|
(add-hook 'doom-init-hook #'ivy-mode)
|
2017-02-22 04:27:23 -05:00
|
|
|
:config
|
2017-05-10 14:05:52 +02:00
|
|
|
(setq ivy-height 12
|
2017-02-13 04:54:12 -05:00
|
|
|
ivy-do-completion-in-region nil
|
|
|
|
ivy-wrap t
|
|
|
|
ivy-fixed-height-minibuffer t
|
2017-02-22 04:27:23 -05:00
|
|
|
projectile-completion-system 'ivy
|
|
|
|
smex-completion-method 'ivy
|
2017-03-08 21:34:52 -05:00
|
|
|
;; Don't use ^ as initial input
|
|
|
|
ivy-initial-inputs-alist nil
|
2017-02-22 04:27:23 -05:00
|
|
|
;; highlight til EOL
|
2017-05-19 05:45:11 -04:00
|
|
|
ivy-format-function #'ivy-format-function-line
|
|
|
|
;; disable magic slash on non-match
|
2018-01-08 14:41:41 -05:00
|
|
|
ivy-magic-slash-non-match-action nil
|
|
|
|
;; don't show recent files in switch-buffer
|
|
|
|
ivy-use-virtual-buffers nil
|
|
|
|
;; ...but if that ever changes, show their full path
|
|
|
|
ivy-virtual-abbreviate 'full)
|
2017-02-13 04:54:12 -05:00
|
|
|
|
2017-05-29 00:58:12 +02:00
|
|
|
(after! magit (setq magit-completing-read-function #'ivy-completing-read))
|
|
|
|
(after! yasnippet (push #'+ivy-yas-prompt yas-prompt-functions))
|
2017-02-22 04:27:23 -05:00
|
|
|
|
2018-01-27 20:57:02 -05:00
|
|
|
(map! [remap switch-to-buffer] #'ivy-switch-buffer
|
|
|
|
[remap persp-switch-to-buffer] #'+ivy/switch-workspace-buffer
|
|
|
|
[remap imenu-anywhere] #'ivy-imenu-anywhere)
|
2017-02-22 04:27:23 -05:00
|
|
|
|
2017-12-17 00:03:14 -05:00
|
|
|
(nconc ivy-sort-functions-alist
|
|
|
|
'((persp-kill-buffer . nil)
|
|
|
|
(persp-remove-buffer . nil)
|
|
|
|
(persp-add-buffer . nil)
|
|
|
|
(persp-switch . nil)
|
|
|
|
(persp-window-switch . nil)
|
|
|
|
(persp-frame-switch . nil)
|
|
|
|
(+workspace/switch-to . nil)
|
|
|
|
(+workspace/delete . nil))))
|
2017-02-13 04:54:12 -05:00
|
|
|
|
|
|
|
|
2018-01-08 14:41:41 -05:00
|
|
|
;; Show more buffer information in switch-buffer commands
|
|
|
|
(def-package! ivy-rich
|
|
|
|
:after ivy
|
|
|
|
:config
|
2018-01-08 19:07:21 -05:00
|
|
|
(dolist (cmd '(ivy-switch-buffer +ivy/switch-workspace-buffer
|
|
|
|
counsel-projectile-switch-to-buffer))
|
2018-01-08 14:41:41 -05:00
|
|
|
(ivy-set-display-transformer cmd '+ivy-buffer-transformer)))
|
|
|
|
|
|
|
|
|
2017-02-23 00:06:12 -05:00
|
|
|
(def-package! swiper :commands (swiper swiper-all))
|
2017-02-21 16:03:44 -05:00
|
|
|
|
|
|
|
|
2017-02-23 00:06:12 -05:00
|
|
|
(def-package! counsel
|
2018-01-27 20:57:02 -05:00
|
|
|
:commands (counsel-ag counsel-rg counsel-pt counsel-apropos counsel-bookmark
|
|
|
|
counsel-describe-function counsel-describe-variable
|
|
|
|
counsel-describe-face counsel-M-x counsel-file-jump
|
|
|
|
counsel-find-file counsel-find-library counsel-info-lookup-symbol
|
|
|
|
counsel-imenu counsel-recentf counsel-yank-pop)
|
|
|
|
:init
|
|
|
|
(map! [remap apropos] #'counsel-apropos
|
|
|
|
[remap bookmark-jump] #'counsel-bookmark
|
|
|
|
[remap describe-face] #'counsel-describe-face
|
|
|
|
[remap describe-function] #'counsel-describe-function
|
|
|
|
[remap describe-variable] #'counsel-describe-variable
|
|
|
|
[remap execute-extended-command] #'counsel-M-x
|
|
|
|
[remap find-file] #'counsel-find-file
|
|
|
|
[remap find-library] #'counsel-find-library
|
|
|
|
[remap yank-pop] #'counsel-yank-pop
|
|
|
|
[remap info-lookup-symbol] #'counsel-info-lookup-symbol
|
|
|
|
[remap imenu] #'counsel-imenu
|
|
|
|
[remap recentf-open-files] #'counsel-recentf)
|
2017-02-13 21:11:54 -05:00
|
|
|
:config
|
2017-02-13 04:54:12 -05:00
|
|
|
(setq counsel-find-file-ignore-regexp "\\(?:^[#.]\\)\\|\\(?:[#~]$\\)\\|\\(?:^Icon?\\)")
|
|
|
|
|
2018-01-27 20:57:02 -05:00
|
|
|
;; Dim recentf entries that are not in the current project.
|
|
|
|
(ivy-set-display-transformer #'counsel-recentf #'+ivy-recentf-transformer)
|
|
|
|
|
2017-05-12 11:50:05 +02:00
|
|
|
;; Configure `counsel-rg', `counsel-ag' & `counsel-pt'
|
|
|
|
(dolist (cmd '(counsel-ag counsel-rg counsel-pt))
|
|
|
|
(ivy-add-actions
|
|
|
|
cmd
|
|
|
|
'(("O" +ivy-git-grep-other-window-action "open in other window"))))
|
2017-02-13 04:54:12 -05:00
|
|
|
|
2018-01-15 00:43:17 -05:00
|
|
|
;; Removes character limit from `counsel-ag-function'
|
|
|
|
;;
|
|
|
|
;; This may need to be updated frequently, to meet changes upstream
|
|
|
|
;; counsel-ag, counsel-rg and counsel-pt all use this function
|
2017-05-06 16:41:17 +02:00
|
|
|
(advice-add #'counsel-ag-function :override #'+ivy*counsel-ag-function))
|
2017-02-13 04:54:12 -05:00
|
|
|
|
2017-02-19 18:41:37 -05:00
|
|
|
|
2018-01-27 20:57:02 -05:00
|
|
|
(def-package! counsel-projectile
|
|
|
|
:commands (counsel-projectile-find-file counsel-projectile-find-dir counsel-projectile-switch-to-buffer
|
2018-01-28 03:34:18 -05:00
|
|
|
counsel-projectile-grep counsel-projectile-ag counsel-projectile-switch-project)
|
2018-01-27 20:57:02 -05:00
|
|
|
:init
|
|
|
|
(map! [remap projectile-find-file] #'counsel-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
|
2018-01-28 03:34:18 -05:00
|
|
|
[remap projectile-ag] #'counsel-projectile-ag
|
|
|
|
[remap projectile-switch-project] #'counsel-projectile-switch-project)
|
2018-01-27 20:57:02 -05:00
|
|
|
:config
|
|
|
|
;; Highlight entries that have been visited
|
|
|
|
(ivy-set-display-transformer #'counsel-projectile-find-file #'+ivy-projectile-find-file-transformer))
|
|
|
|
|
|
|
|
|
2017-02-19 18:41:37 -05:00
|
|
|
;; Used by `counsel-M-x'
|
2017-02-23 00:06:12 -05:00
|
|
|
(def-package! smex
|
2017-02-19 18:41:37 -05:00
|
|
|
:commands (smex smex-major-mode-commands)
|
|
|
|
:config
|
|
|
|
(setq smex-save-file (concat doom-cache-dir "/smex-items"))
|
|
|
|
(smex-initialize))
|
|
|
|
|
2017-09-23 16:26:30 +02:00
|
|
|
|
|
|
|
(def-package! ivy-hydra
|
|
|
|
:commands (+ivy@coo/body ivy-dispatching-done-hydra)
|
|
|
|
:init
|
|
|
|
(map! :map ivy-minibuffer-map
|
|
|
|
"C-o" #'+ivy@coo/body
|
|
|
|
"M-o" #'ivy-dispatching-done-hydra)
|
|
|
|
:config
|
|
|
|
(def-hydra! +ivy@coo (:hint nil :color pink)
|
|
|
|
"
|
|
|
|
Move ^^^^^^^^^^ | Call ^^^^ | Cancel^^ | Options^^ | Action _w_/_s_/_a_: %s(ivy-action-name)
|
|
|
|
----------^^^^^^^^^^-+--------------^^^^-+-------^^-+--------^^-+---------------------------------
|
|
|
|
_g_ ^ ^ _k_ ^ ^ _u_ | _f_orward _o_ccur | _i_nsert | _c_alling: %-7s(if ivy-calling \"on\" \"off\") _C_ase-fold: %-10`ivy-case-fold-search
|
|
|
|
^↨^ _h_ ^+^ _l_ ^↕^ | _RET_ done ^^ | _q_uit | _m_atcher: %-7s(ivy--matcher-desc) _t_runcate: %-11`truncate-lines
|
|
|
|
_G_ ^ ^ _j_ ^ ^ _d_ | _TAB_ alt-done ^^ | ^ ^ | _<_/_>_: shrink/grow
|
|
|
|
"
|
|
|
|
;; arrows
|
|
|
|
("j" ivy-next-line)
|
|
|
|
("k" ivy-previous-line)
|
|
|
|
("l" ivy-alt-done)
|
|
|
|
("h" ivy-backward-delete-char)
|
|
|
|
("g" ivy-beginning-of-buffer)
|
|
|
|
("G" ivy-end-of-buffer)
|
|
|
|
("d" ivy-scroll-up-command)
|
|
|
|
("u" ivy-scroll-down-command)
|
|
|
|
("e" ivy-scroll-down-command)
|
|
|
|
;; actions
|
|
|
|
("q" keyboard-escape-quit :exit t)
|
|
|
|
("C-g" keyboard-escape-quit :exit t)
|
|
|
|
("<escape>" keyboard-escape-quit :exit t)
|
|
|
|
("C-o" nil)
|
|
|
|
("i" nil)
|
|
|
|
("TAB" ivy-alt-done :exit nil)
|
|
|
|
("C-j" ivy-alt-done :exit nil)
|
|
|
|
("RET" ivy-done :exit t)
|
|
|
|
("C-m" ivy-done :exit t)
|
2017-12-08 22:53:45 -05:00
|
|
|
("C-SPC" ivy-call-and-recenter :exit nil)
|
2017-09-23 16:26:30 +02:00
|
|
|
("f" ivy-call)
|
|
|
|
("c" ivy-toggle-calling)
|
|
|
|
("m" ivy-toggle-fuzzy)
|
|
|
|
(">" ivy-minibuffer-grow)
|
|
|
|
("<" ivy-minibuffer-shrink)
|
|
|
|
("w" ivy-prev-action)
|
|
|
|
("s" ivy-next-action)
|
|
|
|
("a" ivy-read-action)
|
|
|
|
("t" (setq truncate-lines (not truncate-lines)))
|
|
|
|
("C" ivy-toggle-case-fold)
|
|
|
|
("o" ivy-occur :exit t)))
|
2018-01-14 02:04:30 -05:00
|
|
|
|
|
|
|
|
|
|
|
(def-package! wgrep
|
|
|
|
:commands (wgrep-setup wgrep-change-to-wgrep-mode)
|
|
|
|
:config (setq wgrep-auto-save-buffer t))
|