[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 f2876014ad: Add customizale faces for tree-sitter explorer
From: |
Yuan Fu |
Subject: |
emacs-29 f2876014ad: Add customizale faces for tree-sitter explorer |
Date: |
Sun, 11 Dec 2022 17:51:42 -0500 (EST) |
branch: emacs-29
commit f2876014adbe15269ecac77cd4ce51becd0ee1c0
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
Add customizale faces for tree-sitter explorer
* lisp/treesit.el (treesit-explorer-anonymous-node)
(treesit-explorer-field-name): New face.
(treesit--explorer-draw-node): Use the new faces.
(treesit-explore-mode): Change playground to explorer.
---
lisp/treesit.el | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/lisp/treesit.el b/lisp/treesit.el
index 85154d0d1c..2ca4f1c7dd 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -1839,6 +1839,18 @@ to the offending pattern and highlight the pattern."
;;; Explorer
+(defface treesit-explorer-anonymous-node
+ (let ((display t)
+ (atts '(:inherit shadow)))
+ `((,display . ,atts)))
+ "Face for anonymous nodes in tree-sitter explorer.")
+
+(defface treesit-explorer-field-name
+ (let ((display t)
+ (atts nil))
+ `((,display . ,atts)))
+ "Face for field names in tree-sitter explorer.")
+
(defvar-local treesit--explorer-buffer nil
"Buffer used to display the syntax tree.")
@@ -2017,7 +2029,8 @@ leaves point at the end of the last line of NODE."
;; draw everything in one line, other wise draw field name and the
;; rest of the node in two lines.
(when field-name
- (insert field-name ": ")
+ (insert (propertize (concat field-name ": ")
+ 'face 'treesit-explorer-field-name))
(when (and children (not all-children-inline))
(insert "\n")
(indent-to-column (1+ before-field-column))))
@@ -2076,7 +2089,7 @@ leaves point at the end of the last line of NODE."
(overlay-put ov 'treesit-node node)
(overlay-put ov 'evaporate t)
(when (not named)
- (overlay-put ov 'face 'shadow)))))
+ (overlay-put ov 'face 'treesit-explorer-anonymous-node)))))
(define-derived-mode treesit--explorer-tree-mode special-mode
"TS Explorer"
@@ -2095,7 +2108,7 @@ window."
(unless (buffer-live-p treesit--explorer-buffer)
(setq-local treesit--explorer-buffer
(get-buffer-create
- (format "*tree-sitter playground for %s*"
+ (format "*tree-sitter explorer for %s*"
(buffer-name))))
(setq-local treesit--explorer-language
(intern (completing-read
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-29 f2876014ad: Add customizale faces for tree-sitter explorer,
Yuan Fu <=