aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Troestler2023-11-30 00:13:10 +0100
committerDmitry Gutov2023-12-02 01:55:02 +0200
commitfbaf113bf38ee7db8416f0c0581d479c40b2d69c (patch)
treee06f651663abfc3019e2e332bd9ed27368dc93ac
parentbd62bdbc680833bb730b114e005e41df8dc97900 (diff)
downloademacs-fbaf113bf38ee7db8416f0c0581d479c40b2d69c.tar.gz
emacs-fbaf113bf38ee7db8416f0c0581d479c40b2d69c.zip
rust-ts-mode: appropriately fontify doc strings
* lisp/progmodes/rust-ts-mode.el (rust-ts-mode--comment-docstring): New function. (rust-ts-mode--font-lock-settings): Use it (https://lists.gnu.org/archive/html/emacs-devel/2023-12/msg00019.html).
-rw-r--r--lisp/progmodes/rust-ts-mode.el13
1 files changed, 12 insertions, 1 deletions
diff --git a/lisp/progmodes/rust-ts-mode.el b/lisp/progmodes/rust-ts-mode.el
index 999c1d7ae96..a07634199ff 100644
--- a/lisp/progmodes/rust-ts-mode.el
+++ b/lisp/progmodes/rust-ts-mode.el
@@ -147,7 +147,7 @@
147 147
148 :language 'rust 148 :language 'rust
149 :feature 'comment 149 :feature 'comment
150 '(([(block_comment) (line_comment)]) @font-lock-comment-face) 150 '(([(block_comment) (line_comment)]) @rust-ts-mode--comment-docstring)
151 151
152 :language 'rust 152 :language 'rust
153 :feature 'delimiter 153 :feature 'delimiter
@@ -287,6 +287,17 @@
287 '((ERROR) @font-lock-warning-face)) 287 '((ERROR) @font-lock-warning-face))
288 "Tree-sitter font-lock settings for `rust-ts-mode'.") 288 "Tree-sitter font-lock settings for `rust-ts-mode'.")
289 289
290(defun rust-ts-mode--comment-docstring (node override start end &rest _args)
291 "Use the comment or documentation face appropriately for comments."
292 (let* ((beg (treesit-node-start node))
293 (end (treesit-node-end node))
294 (face (save-excursion
295 (goto-char beg)
296 (if (looking-at "///")
297 'font-lock-doc-face
298 'font-lock-comment-face))))
299 (treesit-fontify-with-override beg end face override start end)))
300
290(defun rust-ts-mode--fontify-scope (node override start end &optional tail-p) 301(defun rust-ts-mode--fontify-scope (node override start end &optional tail-p)
291 (let* ((case-fold-search nil) 302 (let* ((case-fold-search nil)
292 (face 303 (face