From 3ef2abfb22b4de967f00bd35715579ad88dcfefe Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 10 Apr 2019 19:22:29 -0400 Subject: [PATCH] Improve ivy-switch-buffer transformer - Highlights remote/tramp files with ivy-remote face - Highlights non-file-visiting buffers with ivy-subdir face - Highlight modified buffers with ivy-modified-buffer face - Disable built-in ivy-switch-buffer transformer (redundant with our own transformer) --- modules/completion/ivy/autoload/ivy.el | 15 ++++++++++++--- modules/completion/ivy/config.el | 4 ++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/modules/completion/ivy/autoload/ivy.el b/modules/completion/ivy/autoload/ivy.el index 33cd6cd2e..055a64ea0 100644 --- a/modules/completion/ivy/autoload/ivy.el +++ b/modules/completion/ivy/autoload/ivy.el @@ -19,9 +19,18 @@ Buffers that are considered unreal (see `doom-real-buffer-p') are dimmed with `+ivy-buffer-unreal-face'." - (if (doom-real-buffer-p (get-buffer candidate)) - candidate - (propertize candidate 'face +ivy-buffer-unreal-face))) + (let ((b (get-buffer candidate))) + (cond ((ignore-errors + (file-remote-p + (buffer-local-value 'default-directory b))) + (ivy-append-face candidate 'ivy-remote)) + ((doom-unreal-buffer-p b) + (ivy-append-face candidate +ivy-buffer-unreal-face)) + ((not (buffer-file-name b)) + (ivy-append-face candidate 'ivy-subdir)) + ((buffer-modified-p b) + (ivy-append-face candidate 'ivy-modified-buffer)) + (candidate)))) ;;;###autoload (defun +ivy-rich-buffer-icon (candidate) diff --git a/modules/completion/ivy/config.el b/modules/completion/ivy/config.el index fafaf372e..8fc54d88b 100644 --- a/modules/completion/ivy/config.el +++ b/modules/completion/ivy/config.el @@ -106,6 +106,10 @@ immediately runs it on the current candidate (ending the ivy session)." ((all-the-icons-icon-for-file (:width 2 :align right)) (ivy-rich-candidate))))))) + ;; Remove built-in coloring of buffer list; we do our own + (setq ivy-switch-buffer-faces-alist nil) + (ivy-set-display-transformer 'internal-complete-buffer nil) + ;; Highlight buffers differently based on whether they're in the same project ;; as the current project or not. (let* ((plist (plist-get ivy-rich-display-transformers-list 'ivy-switch-buffer))