summaryrefslogtreecommitdiff
path: root/lisp/treesit.el
diff options
context:
space:
mode:
authorYuan Fu <casouri@gmail.com>2022-12-11 14:43:58 -0800
committerYuan Fu <casouri@gmail.com>2022-12-11 14:51:33 -0800
commitf2876014adbe15269ecac77cd4ce51becd0ee1c0 (patch)
tree178b0e77700d9d25eef1f7dc54a02a1ee8e08028 /lisp/treesit.el
parent3e349ee1198c7fc5187975c3e52e805a44f5b84b (diff)
downloademacs-f2876014adbe15269ecac77cd4ce51becd0ee1c0.tar.gz
emacs-f2876014adbe15269ecac77cd4ce51becd0ee1c0.tar.bz2
emacs-f2876014adbe15269ecac77cd4ce51becd0ee1c0.zip
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.
Diffstat (limited to 'lisp/treesit.el')
-rw-r--r--lisp/treesit.el19
1 files changed, 16 insertions, 3 deletions
diff --git a/lisp/treesit.el b/lisp/treesit.el
index 85154d0d1c7..2ca4f1c7ddc 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