Merge pull request #1366 from flatwhatson/fix-ivy-rich

Fixes for ivy-switch-buffer icons
This commit is contained in:
Henrik Lissner 2019-04-26 14:39:23 -04:00 committed by GitHub
commit 15e47cb9f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 9 deletions

View file

@ -34,14 +34,19 @@ Buffers that are considered unreal (see `doom-real-buffer-p') are dimmed with
;;;###autoload
(defun +ivy-rich-buffer-icon (candidate)
"Display the icon for CANDIDATE buffer.
Otherwise show the fundamental-mode icon."
(with-current-buffer candidate
(let ((icon (all-the-icons-icon-for-mode major-mode)))
(if (symbolp icon)
(all-the-icons-icon-for-mode 'fundamental-mode)
icon))))
"Display the icon for CANDIDATE buffer."
;; NOTE This is inspired by `all-the-icons-ivy-buffer-transformer', minus the
;; buffer name and extra padding as those are handled by `ivy-rich'.
(propertize "\t" 'display
(if-let* ((buffer (get-buffer candidate))
(mode (buffer-local-value 'major-mode buffer)))
(or
(all-the-icons-ivy--icon-for-mode mode)
(all-the-icons-ivy--icon-for-mode (get mode 'derived-mode-parent))
(funcall
all-the-icons-ivy-family-fallback-for-buffer
all-the-icons-ivy-name-fallback-for-buffer))
(all-the-icons-icon-for-file candidate))))
;;

View file

@ -88,7 +88,7 @@ immediately runs it on the current candidate (ending the ivy session)."
:after ivy
:config
(when (featurep! +icons)
(cl-pushnew '(all-the-icons-ivy-icon-for-file (:width 2 :align right))
(cl-pushnew '(+ivy-rich-buffer-icon)
(cadr (plist-get ivy-rich-display-transformers-list
'ivy-switch-buffer))))