0

I used to use Helm and I really liked it. After watching System Crafter's YouTube series called "Emacs from Scratch", I decided to use the configuration showcased. The YouTuber prefers Ivy instead of Helm. This is the configuration for the first episode when Ivy is shown for the first time.

He does the installation and configuration via use-package. This is my almost identical use of the same approach:

;; Using Ivy from System Crafters
(use-package ivy
  :diminish ;keeps ivy out of the mode line
  :bind (("C-s" . swiper)
         :map ivy-minibuffer-map
         ;("TAB" . ivy-alt-done)    
         ("C-l" . ivy-alt-done)
         ("C-j" . ivy-next-line)
         ("C-k" . ivy-previous-line)
         :map ivy-switch-buffer-map
         ("C-k" . ivy-previous-line)
         ("C-l" . ivy-done)
         ("C-d" . ivy-switch-buffer-kill)
         :map ivy-reverse-i-search-map
         ("C-k" . ivy-previous-line)
         ("C-d" . ivy-reverse-i-search-kill))
  :config
  (ivy-mode 1))

I miss two things from Helm: (1) Helm fuzzy matching, and (2) Helm's prompt-buffer listing the last used command at the top of the prompt-buffer.

Since Ivy is configurable, I have been trying to fulfill my desires. Some answers in Stack Exchange pointed to using:

(setq ivy-re-builders-alist
      '((swiper . ivy--regex-plus)
        (t      . ivy--regex-fuzzy)))

Thus, I tried tweaking the ivy configuration to be:

;; Using Ivy from System Crafters
(use-package ivy
  :diminish ;keeps ivy out of the mode line
  :bind (("C-s" . swiper)
         :map ivy-minibuffer-map
         ;("TAB" . ivy-alt-done)    
         ("C-l" . ivy-alt-done)
         ("C-j" . ivy-next-line)
         ("C-k" . ivy-previous-line)
         :map ivy-switch-buffer-map
         ("C-k" . ivy-previous-line)
         ("C-l" . ivy-done)
         ("C-d" . ivy-switch-buffer-kill)
         :map ivy-reverse-i-search-map
         ("C-k" . ivy-previous-line)
         ("C-d" . ivy-reverse-i-search-kill))
  :config
  '((ivy-mode 1)
    (t      . ivy--regex-fuzzy)))

But, it did not work out to solve problem (1). At the same time, I tried installing ivy-prescient to have the last used command listed first and solve problem (2). It seems to work, not sure if this is the best approach, though:

;; Make the last used command be the first-one
(use-package ivy-prescient
  :init
  (ivy-prescient-mode 1))

Pedro Delfino
  • 1,369
  • 3
  • 13

1 Answers1

0

This solved the fuzzy match problem (not sure if this is the best way):

(use-package ivy
  :diminish ;keeps ivy out of the mode line
  :bind (("C-s" . swiper)
         :map ivy-minibuffer-map
         ;("TAB" . ivy-alt-done)    
         ("C-l" . ivy-alt-done)
         ("C-j" . ivy-next-line)
         ("C-k" . ivy-previous-line)
         :map ivy-switch-buffer-map
         ("C-k" . ivy-previous-line)
         ("C-l" . ivy-done)
         ("C-d" . ivy-switch-buffer-kill)
         :map ivy-reverse-i-search-map
         ("C-k" . ivy-previous-line)
         ("C-d" . ivy-reverse-i-search-kill))
  :config
  '((ivy-mode 1)
    (ivy--regex-fuzzy 1)))

I am still not sure if this is the best approach for ivy-prescient. But it seems to do the trick:

;; Make the last used command be the first-one
(use-package ivy-prescient
  :init
  (ivy-prescient-mode 1))

Pedro Delfino
  • 1,369
  • 3
  • 13