2017-02-13 04:54:12 -05:00
|
|
|
;;; completion/ivy/packages.el
|
|
|
|
|
2017-05-10 06:13:14 +02:00
|
|
|
(defvar +ivy-task-tags '(("TODO" . warning)
|
|
|
|
("FIXME" . error))
|
|
|
|
"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-05-10 05:20:54 +02:00
|
|
|
"A factory function that returns an interactive lamba that sets the current
|
|
|
|
ivy action and immediately runs it on the current candidate (ending the ivy
|
|
|
|
session)."
|
|
|
|
`(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-02-23 00:06:12 -05:00
|
|
|
(def-package! ivy :demand t
|
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
|
|
|
|
ivy-magic-slash-non-match-action nil)
|
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
|
|
|
|
|
|
|
(ivy-mode +1)
|
2017-02-13 21:11:54 -05:00
|
|
|
|
2017-02-23 00:06:12 -05:00
|
|
|
(map! :map ivy-mode-map
|
2017-04-17 02:17:10 -04:00
|
|
|
[remap describe-face] #'counsel-describe-face
|
|
|
|
[remap find-file] #'counsel-find-file
|
|
|
|
[remap switch-to-buffer] #'+ivy/switch-buffer
|
|
|
|
[remap persp-switch-to-buffer] #'+ivy/switch-workspace-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
|
2017-05-10 05:28:50 +02:00
|
|
|
[remap execute-extended-command] #'counsel-M-x
|
|
|
|
[remap describe-function] #'counsel-describe-function
|
|
|
|
[remap describe-variable] #'counsel-describe-variable
|
|
|
|
[remap describe-face] #'counsel-describe-face)
|
2017-02-22 04:27:23 -05:00
|
|
|
|
2017-02-23 00:06:12 -05:00
|
|
|
(when (featurep! :feature workspaces)
|
2017-02-22 04:27:23 -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
|
|
|
|
|
|
|
|
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
|
2017-02-13 04:54:12 -05:00
|
|
|
:after ivy
|
2017-02-13 21:11:54 -05:00
|
|
|
:config
|
2017-05-10 05:20:54 +02:00
|
|
|
(require 'counsel-projectile)
|
2017-02-13 04:54:12 -05:00
|
|
|
(setq counsel-find-file-ignore-regexp "\\(?:^[#.]\\)\\|\\(?:[#~]$\\)\\|\\(?:^Icon?\\)")
|
|
|
|
|
2017-05-12 11:50:05 +02:00
|
|
|
;; Configure `counsel-rg', `counsel-ag' & `counsel-pt'
|
2017-05-15 14:07:12 +02:00
|
|
|
(set! :popup 'ivy-occur-grep-mode :size (+ 2 ivy-height) :regexp t :autokill t)
|
2017-02-20 20:43:08 -05:00
|
|
|
|
2017-05-12 11:50:05 +02:00
|
|
|
(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
|
|
|
|
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
|
|
|
|
|
|
|
;; 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))
|
|
|
|
|