diff options
author | David Morgan <djm_uk@protonmail.com> | 2024-09-26 17:02:45 +0100 |
---|---|---|
committer | David Morgan <djm_uk@protonmail.com> | 2024-09-26 17:02:45 +0100 |
commit | 454a1bb68c7b0556df952f45e9f13fd6892f356b (patch) | |
tree | 001b5ca76a2c8d59cb41c5984611b4f0ef0fac77 /.emacs.d | |
parent | aaf01401f10d43dc8dfe12b050a155df0baeeda4 (diff) | |
download | dotfiles-454a1bb68c7b0556df952f45e9f13fd6892f356b.tar.gz |
Format directories and enabled minor modes differently
Diffstat (limited to '.emacs.d')
-rw-r--r-- | .emacs.d/lisp/init-minibuffer.el | 33 |
1 files changed, 30 insertions, 3 deletions
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 |