From 454a1bb68c7b0556df952f45e9f13fd6892f356b Mon Sep 17 00:00:00 2001 From: David Morgan Date: Thu, 26 Sep 2024 17:02:45 +0100 Subject: Format directories and enabled minor modes differently --- .emacs.d/lisp/init-minibuffer.el | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to '.emacs.d/lisp/init-minibuffer.el') diff --git a/.emacs.d/lisp/init-minibuffer.el b/.emacs.d/lisp/init-minibuffer.el index 93e41d8..6e6d515 100644 --- a/.emacs.d/lisp/init-minibuffer.el +++ b/.emacs.d/lisp/init-minibuffer.el @@ -108,12 +108,39 @@ (vertico-multiform-vertical) (setcar vertico-multiform--stack '(vertico-buffer-mode vertico-grid-mode)) (vertico-multiform--toggle 1))) + + ;; https://github.com/minad/vertico/wiki#candidate-display-transformations-custom-candidate-highlighting + (defvar +vertico-transform-functions nil) + (cl-defmethod vertico--format-candidate :around + (cand prefix suffix index start &context ((not +vertico-transform-functions) null)) + (dolist (fun (ensure-list +vertico-transform-functions)) + (setq cand (funcall fun cand))) + (cl-call-next-method cand prefix suffix index start)) + (defun +vertico-highlight-directory (file) + "If FILE ends with a slash, highlight it as a directory." + (if (string-suffix-p "/" file) + (propertize file 'face 'marginalia-file-priv-dir) + file)) + (defun +vertico-highlight-enabled-mode (cmd) + "If MODE is enabled, highlight it as font-lock-doc-face." + (let ((sym (intern cmd))) + (if (or (eq sym major-mode) + (and + (memq sym minor-mode-list) + (boundp sym))) + (propertize cmd 'face 'font-lock-doc-face) + cmd))) + (setq vertico-multiform-commands ;; See twice as many lines - '((consult-line grid))) + '((consult-line grid) + (execute-extended-command + (+vertico-transform-functions . +vertico-highlight-enabled-mode)))) (setq vertico-multiform-categories - '((imenu grid))) - :bind (:map vertico-multiform-map ("M-H" . vertico-multiform-buffer-grid))) + '((file (+vertico-transform-functions . +vertico-highlight-directory)) + (imenu grid))) + :bind (:map vertico-multiform-map + ("M-H" . vertico-multiform-buffer-grid))) (use-extension vertico vertico-directory :config -- cgit 1.4.1-2-gfad0