Closed sebastiaanspeck closed 1 year ago
This issue has been automatically marked as stale because it has not had recent activity (this bot only works as a reminder, it will not close issues).
For performance reasons treemacs uses hash tables for its icon matching, so regexes are are no-go. You can at most change what treemacs considers a file's extension, that part is handled via regex. Look at treemacs-file-extension-regex
. The default choices are about matching things after the first or last period, but maybe you can change it to something that suits you.
Besides this issue, is the function treemacs-get-icon-value case-sensitive?
Yes. Internally treemacs will downcase everything, so you should do the same.
Okay, but given the file Dockerfile-backend
and Dockerfile-frontend
, how can I add the Dockerfile-icon to those?
Get the latest version of treemacs and you'll be able to create an override to check for the dockerfile prefix like this:
(advice-add
#'treemacs--file-extension
:around
(defun treemacs-override (original-fn filename)
(if (string-prefix-p "dockerfile" (downcase filename))
"dockerfile"
(funcall original-fn filename))))
Then make sure to create an icon for a lowercase "dockerfile" extension and you should be good to go.
Would be great if the above would work. I do have some Dockerfiles that are called:
I could add
(add-to-list 'nerd-icons-regexp-icon-alist '("^Dockerfile.*$" nerd-icons-sucicon "nf-seti-docker" :face nerd-icons-cyan))
to the regexp for nerd-icons, but the regexp-icon-alist can't be used for treemacs-create-icon.Besides this issue, is the function
treemacs-get-icon-value
case-sensitive?(treemacs-get-icon-value "dockerfile" nil "nerd-icons")
--> results in a icon(treemacs-get-icon-value "Dockerfile" nil "nerd-icons")
--> nilIt does display the icon for dockerfile when having a Dockerfile in treemacs, so thats no issue.