summaryrefslogtreecommitdiffstats
path: root/lisp/bandali-ivy.el
blob: 438360ff553e75b97d973ffa241205ea20c081f0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
;;; bandali-ivy.el --- bandali's Ivy setup           -*- lexical-binding: t; -*-

;; Copyright (C) 2018-2020  Amin Bandali

;; Author: Amin Bandali <bandali@gnu.org>
;; Keywords: matching

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;; My configuration for Ivy and family.

;;; Code:

(use-package ivy
  :defer 0.3
  :bind
  (:map ivy-minibuffer-map
   ([escape] . keyboard-escape-quit)
   ([S-up]   . ivy-previous-history-element)
   ([S-down] . ivy-next-history-element)
   ("DEL"    . ivy-backward-delete-char))
  :config
  (setq ivy-wrap t
        ;; ivy-height 14
        ivy-use-virtual-buffers t
        ivy-virtual-abbreviate 'abbreviate
        ivy-count-format "%d/%d ")

  (defvar b/ivy-ignore-buffer-modes '(magit-mode erc-mode dired-mode))
  (defun b/ivy-ignore-buffer-p (str)
    "Return non-nil if str names a buffer with a major mode
derived from one of `b/ivy-ignore-buffer-modes'.

This function is intended for use with `ivy-ignore-buffers'."
    (let* ((buf (get-buffer str))
           (mode (and buf (buffer-local-value 'major-mode buf))))
      (and mode
           (apply #'provided-mode-derived-p mode b/ivy-ignore-buffer-modes))))
  (add-to-list 'ivy-ignore-buffers 'b/ivy-ignore-buffer-p)

  (ivy-mode 1))

(use-package swiper
  :demand
  :after ivy
  :bind (("C-S-s" . swiper-isearch)))

(use-package counsel
  :demand
  :after ivy
  :bind (("C-c f r" . counsel-recentf)
         :map minibuffer-local-map
         ("C-r" . counsel-minibuffer-history))
  :config
  (counsel-mode 1)
  (defalias 'locate #'counsel-locate))

(provide 'bandali-ivy)
;;; bandali-ivy.el ends here