Update 17 drones and commit a bunch of changes
[~bandali/configs] / lisp / bandali-ivy.el
1 ;;; bandali-ivy.el --- bandali's Ivy setup -*- lexical-binding: t; -*-
2
3 ;; Copyright (C) 2018-2020 Amin Bandali
4
5 ;; Author: Amin Bandali <bandali@gnu.org>
6 ;; Keywords: matching
7
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
12
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
17
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
20
21 ;;; Commentary:
22
23 ;; My configuration for Ivy and family.
24
25 ;;; Code:
26
27 (use-package ivy
28 :defer 0.3
29 :bind
30 (:map ivy-minibuffer-map
31 ([escape] . keyboard-escape-quit)
32 ([S-up] . ivy-previous-history-element)
33 ([S-down] . ivy-next-history-element)
34 ("DEL" . ivy-backward-delete-char))
35 :config
36 (setq ivy-wrap t
37 ;; ivy-height 14
38 ivy-use-virtual-buffers t
39 ivy-virtual-abbreviate 'abbreviate
40 ivy-count-format "%d/%d ")
41
42 (defvar b/ivy-ignore-buffer-modes '(magit-mode erc-mode dired-mode))
43 (defun b/ivy-ignore-buffer-p (str)
44 "Return non-nil if str names a buffer with a major mode
45 derived from one of `b/ivy-ignore-buffer-modes'.
46
47 This function is intended for use with `ivy-ignore-buffers'."
48 (let* ((buf (get-buffer str))
49 (mode (and buf (buffer-local-value 'major-mode buf))))
50 (and mode
51 (apply #'provided-mode-derived-p mode b/ivy-ignore-buffer-modes))))
52 (add-to-list 'ivy-ignore-buffers 'b/ivy-ignore-buffer-p)
53
54 (ivy-mode 1))
55
56 (use-package swiper
57 :demand
58 :after ivy
59 :bind (("C-S-s" . swiper-isearch)))
60
61 (use-package counsel
62 :demand
63 :after ivy
64 :bind (("C-c f r" . counsel-recentf)
65 :map minibuffer-local-map
66 ("C-r" . counsel-minibuffer-history))
67 :config
68 (counsel-mode 1)
69 (defalias 'locate #'counsel-locate))
70
71 (provide 'bandali-ivy)
72 ;;; bandali-ivy.el ends here