From 2fa2639d644fed741b647b2e1f1b84d604f09b35 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 14 May 2019 10:06:36 -0400 Subject: [PATCH] Add value column to {describe,helpful}-variable --- modules/completion/ivy/autoload/ivy.el | 27 ++++++++++++++++++++++++++ modules/completion/ivy/config.el | 9 +++++++++ 2 files changed, 36 insertions(+) diff --git a/modules/completion/ivy/autoload/ivy.el b/modules/completion/ivy/autoload/ivy.el index ed92cdce3..212691598 100644 --- a/modules/completion/ivy/autoload/ivy.el +++ b/modules/completion/ivy/autoload/ivy.el @@ -48,6 +48,33 @@ Buffers that are considered unreal (see `doom-real-buffer-p') are dimmed with all-the-icons-ivy-name-fallback-for-buffer)) (all-the-icons-icon-for-file candidate)))) +;;;###autoload +(defun +ivy-rich-describe-variable-transformer (cand) + "Previews the value of the variable in the minibuffer" + (let* ((sym (intern cand)) + (val (and (boundp sym) (symbol-value sym))) + (print-level 3)) + (replace-regexp-in-string + "[\n\t\^[\^M\^@\^G]" " " + (cond ((booleanp val) + (propertize (format "%s" val) 'face + (if (null val) + 'font-lock-comment-face + 'success))) + ((symbolp val) + (propertize (format "'%s" val) + 'face 'highlight-quoted-symbol)) + ((keymapp val) + (propertize "" 'face 'font-lock-constant-face)) + ((listp val) + (prin1-to-string val)) + ((stringp val) + (propertize (format "%S" val) 'face 'font-lock-string-face)) + ((numberp val) + (propertize (format "%s" val) 'face 'highlight-numbers-number)) + ((format "%s" val))) + t))) + ;; ;; Library diff --git a/modules/completion/ivy/config.el b/modules/completion/ivy/config.el index e02a28236..b0a1fb5cb 100644 --- a/modules/completion/ivy/config.el +++ b/modules/completion/ivy/config.el @@ -92,6 +92,15 @@ immediately runs it on the current candidate (ending the ivy session)." (cadr (plist-get ivy-rich-display-transformers-list 'ivy-switch-buffer)))) + ;; Include variable value in `counsel-describe-variable' + (setq ivy-rich-display-transformers-list + (plist-put ivy-rich-display-transformers-list + 'counsel-describe-variable + '(:columns + ((counsel-describe-variable-transformer (:width 40)) ; the original transformer + (+ivy-rich-describe-variable-transformer (:width 50)) + (ivy-rich-counsel-variable-docstring (:face font-lock-doc-face)))))) + ;; 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)