jwiegley / use-package

A use-package declaration for simplifying your .emacs
https://jwiegley.github.io/use-package
GNU General Public License v3.0
4.37k stars 260 forks source link

Combine the ivy and swiper configurations into one. #1049

Closed hongyi-zhao closed 1 year ago

hongyi-zhao commented 1 year ago

I've the following configurations:

;; https://github.com/oantolin/orderless/issues/139#issuecomment-1524899361
(use-package orderless
  :ensure t
  :custom
  (completion-styles '(orderless basic))
  (completion-category-overrides '((file (styles basic partial-completion)))))

;;https://writequit.org/denver-emacs/presentations/2017-04-11-ivy.html#orgc2d4898
(use-package ivy
  :demand
  :config
  (setq ivy-use-virtual-buffers t
        enable-recursive-minibuffers t
        ivy-count-format "%d/%d "
    ivy-re-builders-alist '((t . orderless-ivy-re-builder))
    )
  (add-to-list 'ivy-highlight-functions-alist '(orderless-ivy-re-builder . orderless-ivy-highlight))
  )

;;https://github.com/abo-abo/swiper/issues/2899#issuecomment-890300284
(use-package swiper
  :bind ("C-s" . swiper)
  )

Can I combine the configurations for Swiper and Ivy (the completion framework it depends on) into one as shown above?

See here for the related discussion.

Regards, Zhao

hongyi-zhao commented 1 year ago

The following does the trick:

;; Orderless doesn't work as desired.
;; https://github.com/oantolin/orderless/issues/139#issuecomment-1524899361
(use-package orderless
  :custom
  (completion-styles '(orderless basic))
  (completion-category-overrides '((file (styles basic partial-completion)))))

;;https://writequit.org/denver-emacs/presentations/2017-04-11-ivy.html#orgc2d4898
(use-package ivy
  :config
  (setq ivy-use-virtual-buffers t
        enable-recursive-minibuffers t
        ivy-count-format "%d/%d "
    ivy-re-builders-alist '((t . orderless-ivy-re-builder))
    )
  (add-to-list 'ivy-highlight-functions-alist '(orderless-ivy-re-builder . orderless-ivy-highlight))

  ;;https://github.com/abo-abo/swiper/issues/2899#issuecomment-890300284
  (use-package swiper
    :bind ("C-s" . swiper)
    )
  )