diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-27 21:54:05 -0400 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-27 21:54:05 -0400 |
| commit | f102a092268d24d5dd241e054efbcbd5fd3d4c1c (patch) | |
| tree | ce3b67c332389996e1e1f7c93ba2f1459ab9d1f1 /modules/nerd-icons-config.el | |
| parent | 6e3903d2c7521f5301f61b412ef5fb577057eef3 (diff) | |
| download | dotemacs-f102a092268d24d5dd241e054efbcbd5fd3d4c1c.tar.gz dotemacs-f102a092268d24d5dd241e054efbcbd5fd3d4c1c.zip | |
fix(nerd-icons): color completing-read folders via the completion dir face
The cj/--nerd-icons-color-dir advice forces nerd-icons-yellow onto every dir icon, which wins over nerd-icons-completion's inherit-behind dir face, so setting nerd-icons-completion-dir-face had no visible effect and folders just followed nerd-icons-yellow. Redefine the file-category completion icon to copy the dir icon and prepend nerd-icons-completion-dir-face so it takes the foreground. The copy keeps nerd-icons' memoized original untouched, so dired and dirvish folders are unaffected. Now completing-read folders carry their own color while file icons keep their type face.
Diffstat (limited to 'modules/nerd-icons-config.el')
| -rw-r--r-- | modules/nerd-icons-config.el | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/modules/nerd-icons-config.el b/modules/nerd-icons-config.el index e2edb0717..e38db7d80 100644 --- a/modules/nerd-icons-config.el +++ b/modules/nerd-icons-config.el @@ -72,7 +72,20 @@ every call. The `memq' check skips when the face is already present." :after (nerd-icons marginalia) :hook (marginalia-mode . nerd-icons-completion-marginalia-setup) :config - (nerd-icons-completion-mode)) + (nerd-icons-completion-mode) + ;; The `cj/--nerd-icons-color-dir' advice forces `nerd-icons-yellow' onto every + ;; dir icon, so the package's inherit-behind `nerd-icons-completion-dir-face' + ;; can never win. Redefine the file-category icon so completing-read folders + ;; carry the dir face: copy the icon first (the memoized original stays + ;; untouched, so dired/dirvish folders are unaffected) and prepend the dir face + ;; so it takes the foreground. Files keep their own type face. + (cl-defmethod nerd-icons-completion-get-icon (cand (_cat (eql file))) + (if (string-suffix-p "/" cand) + (let ((icon (copy-sequence + (nerd-icons-icon-for-dir cand :height nerd-icons-completion-icon-size)))) + (add-face-text-property 0 (length icon) 'nerd-icons-completion-dir-face nil icon) + (concat icon " ")) + (concat (nerd-icons-icon-for-file cand :height nerd-icons-completion-icon-size) " ")))) (use-package nerd-icons-ibuffer :after nerd-icons |
