From: Yuan Fu Date: Sun, 11 Dec 2022 22:43:58 +0000 (-0800) Subject: Add customizale faces for tree-sitter explorer X-Git-Tag: emacs-29.0.90~1233 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f2876014adbe15269ecac77cd4ce51becd0ee1c0;p=emacs.git 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. --- 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