-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnerd-icons-side-tree.lisp
42 lines (38 loc) · 2.13 KB
/
nerd-icons-side-tree.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
;; -*- mode: Lisp; coding: utf-8-unix; -*-
;; Copyright (c) 2024, April & May
;; SPDX-License-Identifier: 0BSD
(in-package side-tree)
(defun get-nerd-icon (path &optional opened-p)
(let ((pane (window-text-pane (current-window))))
(multiple-value-bind (sym color)
(nerd-icons:file-to-icon-name path)
(when (and opened-p (eq sym 'nerd-icons:custom-folder-oct))
(setq sym 'nerd-icons:custom-folder-open))
(values (get sym :char)
(list 'face (make-face nil
:font (gp:find-best-font
pane
(gp:make-font-description
:family nerd-icons:*nerd-font-family*
:size (gp:font-description-attribute-value
(gp:font-description (capi:simple-pane-font pane))
:size)))
:foreground (color:get-color-translation color)))))))
(defmethod get-icon :around ((kind (eql :project)) path)
(let ((pane (window-text-pane (current-window))))
(values (get 'nerd-icons:cod-repo :char)
(list 'face (make-face nil
:font (gp:find-best-font
pane
(gp:make-font-description
:family nerd-icons:*nerd-font-family*
:size (gp:font-description-attribute-value
(gp:font-description (capi:simple-pane-font pane))
:size)))
:foreground (editor::face-foreground (editor::find-face 'project-name-face)))))))
(defmethod get-icon :around ((kind (eql :directory)) path)
(get-nerd-icon path))
(defmethod get-icon :around ((kind (eql :directory-opened)) path)
(get-nerd-icon path t))
(defmethod get-icon :around ((kind (eql :file)) path)
(get-nerd-icon path))