diff --git a/modules/completion/ivy/README.org b/modules/completion/ivy/README.org index f4702a357..9feb2af27 100644 --- a/modules/completion/ivy/README.org +++ b/modules/completion/ivy/README.org @@ -4,27 +4,27 @@ #+STARTUP: inlineimages * Table of Contents :TOC_3:noexport: -- [[Description][Description]] - - [[Module Flags][Module Flags]] - - [[Plugins][Plugins]] - - [[Hacks][Hacks]] -- [[Prerequisites][Prerequisites]] - - [[Install][Install]] - - [[MacOS][MacOS]] - - [[Arch Linux][Arch Linux]] -- [[Features][Features]] - - [[Jump-to-file project navigation][Jump-to-file project navigation]] - - [[Project search & replace][Project search & replace]] - - [[In-buffer searching][In-buffer searching]] - - [[Task lookup][Task lookup]] - - [[Ivy integration for various completing commands][Ivy integration for various completing commands]] - - [[General][General]] - - [[Jump to files, buffers or projects)][Jump to files, buffers or projects)]] - - [[Search][Search]] -- [[Configuration][Configuration]] - - [[Enable fuzzy/non-fuzzy search for specific commands][Enable fuzzy/non-fuzzy search for specific commands]] - - [[Change the position of the ivy childframe][Change the position of the ivy childframe]] -- [[Troubleshooting][Troubleshooting]] +- [[#description][Description]] + - [[#module-flags][Module Flags]] + - [[#plugins][Plugins]] + - [[#hacks][Hacks]] +- [[#prerequisites][Prerequisites]] + - [[#install][Install]] + - [[#macos][MacOS]] + - [[#arch-linux][Arch Linux]] +- [[#features][Features]] + - [[#jump-to-file-project-navigation][Jump-to-file project navigation]] + - [[#project-search--replace][Project search & replace]] + - [[#in-buffer-searching][In-buffer searching]] + - [[#task-lookup][Task lookup]] + - [[#ivy-integration-for-various-completing-commands][Ivy integration for various completing commands]] + - [[#general][General]] + - [[#jump-to-files-buffers-or-projects][Jump to files, buffers or projects)]] + - [[#search][Search]] +- [[#configuration][Configuration]] + - [[#enable-fuzzynon-fuzzy-search-for-specific-commands][Enable fuzzy/non-fuzzy search for specific commands]] + - [[#change-the-position-of-the-ivy-childframe][Change the position of the ivy childframe]] +- [[#troubleshooting][Troubleshooting]] * Description This module provides Ivy integration for a variety of Emacs commands, as well as @@ -40,6 +40,8 @@ lighter, simpler and faster in many cases. + =+fuzzy= Enables the fuzzy method for ivy searches. + =+childframe= Causes Ivy to display in a floating child frame, above Emacs. *This requires GUI Emacs 26.1+* ++ =+icons= Enables file icons for switch-{buffer,project}/find-file counsel + commands. ** Plugins + [[https://github.com/abo-abo/swiper][ivy]] @@ -52,6 +54,7 @@ lighter, simpler and faster in many cases. + [[https://github.com/DarwinAwardWinner/amx][amx]] + [[https://github.com/lewang/flx][flx]]* (=+fuzzy=) + [[https://github.com/tumashu/ivy-posframe][ivy-posframe]]* (=+childframe=) ++ [[https://github.com/asok/all-the-icons-ivy][all-the-icons-ivy]]* (=+icons=) ** Hacks + Functions with ivy/counsel equivalents have been globally remapped (like diff --git a/modules/completion/ivy/config.el b/modules/completion/ivy/config.el index fbe32e6b6..7e585a827 100644 --- a/modules/completion/ivy/config.el +++ b/modules/completion/ivy/config.el @@ -1,8 +1,5 @@ ;;; completion/ivy/config.el -*- lexical-binding: t; -*- -(defvar +ivy-buffer-icons nil - "If non-nil, show buffer mode icons in `ivy-switch-buffer' and the like.") - (defvar +ivy-buffer-preview nil "If non-nil, preview buffers while switching, à la `counsel-switch-buffer'. @@ -88,26 +85,12 @@ immediately runs it on the current candidate (ending the ivy session)." (def-package! ivy-rich - :hook (ivy-mode . ivy-rich-mode) + :after ivy :config - (when +ivy-buffer-icons - (cl-pushnew '(+ivy-rich-buffer-icon (:width 2 :align right)) + (when (featurep! +icons) + (cl-pushnew '(all-the-icons-ivy-icon-for-file (:width 2 :align right)) (cadr (plist-get ivy-rich-display-transformers-list - 'ivy-switch-buffer))) - (after! counsel-projectile - (setq ivy-rich-display-transformers-list - (plist-put ivy-rich-display-transformers-list - 'counsel-projectile-switch-project - '(:columns - (((lambda (_) (all-the-icons-octicon "file-directory")) - (:width 2 :align right)) - (ivy-rich-candidate))))) - (setq ivy-rich-display-transformers-list - (plist-put ivy-rich-display-transformers-list - 'counsel-projectile-find-file - '(:columns - ((all-the-icons-icon-for-file (:width 2 :align right)) - (ivy-rich-candidate))))))) + 'ivy-switch-buffer)))) ;; Remove built-in coloring of buffer list; we do our own (setq ivy-switch-buffer-faces-alist nil) @@ -125,7 +108,26 @@ immediately runs it on the current candidate (ending the ivy session)." (dolist (cmd '(+ivy--switch-buffer counsel-projectile-switch-to-buffer)) (setq ivy-rich-display-transformers-list (plist-put ivy-rich-display-transformers-list - cmd ivy-switch-buffer-transformer))))) + cmd ivy-switch-buffer-transformer)))) + + ;; Reload ivy which so changes to `ivy-rich-display-transformers-list' work + (ivy-rich-mode +1)) + + +(def-package! all-the-icons-ivy + :when (featurep! +icons) + :after ivy + :config + ;; `all-the-icons-ivy' is incompatible with ivy-rich's switch-buffer + ;; modifications, so we disable them and merge them ourselves + (setq all-the-icons-ivy-buffer-commands nil) + + (all-the-icons-ivy-setup) + (after! counsel-projectile + (let ((all-the-icons-ivy-file-commands '(counsel-projectile + counsel-projectile-find-file + counsel-projectile-find-dir))) + (all-the-icons-ivy-setup)))) (def-package! counsel @@ -201,8 +203,12 @@ immediately runs it on the current candidate (ending the ivy session)." (def-package! counsel-projectile - :commands (counsel-projectile-find-file counsel-projectile-find-dir counsel-projectile-switch-to-buffer - counsel-projectile-grep counsel-projectile-ag counsel-projectile-switch-project) + :commands (counsel-projectile-find-file + counsel-projectile-find-dir + counsel-projectile-switch-to-buffer + counsel-projectile-grep + counsel-projectile-ag + counsel-projectile-switch-project) :init (map! [remap projectile-find-file] #'+ivy/projectile-find-file [remap projectile-find-dir] #'counsel-projectile-find-dir diff --git a/modules/completion/ivy/packages.el b/modules/completion/ivy/packages.el index ace65cf1b..a61af857e 100644 --- a/modules/completion/ivy/packages.el +++ b/modules/completion/ivy/packages.el @@ -15,3 +15,6 @@ (when (and EMACS26+ (featurep! +childframe)) (package! ivy-posframe)) + +(when (featurep! +icons) + (package! all-the-icons-ivy))