aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjohn muhl2025-05-14 08:53:42 -0500
committerEli Zaretskii2025-08-30 11:31:34 +0300
commit34f3ac6c5b98d79e51bd9bbaf3c5bd89b2faaba3 (patch)
treed0bd595d05995dabcaefe4f237e99193fe046a2c
parentb0efe06551bfed447328c11d6711ffd9fc63dfe4 (diff)
downloademacs-34f3ac6c5b98d79e51bd9bbaf3c5bd89b2faaba3.tar.gz
emacs-34f3ac6c5b98d79e51bd9bbaf3c5bd89b2faaba3.zip
Fontify all comment delimiters in 'lua-ts-mode'
* lisp/progmodes/lua-ts-mode.el (lua-ts--comment-font-lock): Apply 'font-lock-comment-delimiter-face' to the entire span of initial dashes. In particular, this improves the appearance of LuaCATS and EmmyLua style annotations which use "---". * test/lisp/progmodes/lua-ts-mode-resources/font-lock.lua: Add tests. (Bug#79258)
-rw-r--r--lisp/progmodes/lua-ts-mode.el7
-rw-r--r--test/lisp/progmodes/lua-ts-mode-resources/font-lock.lua5
2 files changed, 10 insertions, 2 deletions
diff --git a/lisp/progmodes/lua-ts-mode.el b/lisp/progmodes/lua-ts-mode.el
index 1c1812a7c30..35700255ba4 100644
--- a/lisp/progmodes/lua-ts-mode.el
+++ b/lisp/progmodes/lua-ts-mode.el
@@ -168,10 +168,13 @@ values of OVERRIDE."
168 (let* ((node-start (treesit-node-start node)) 168 (let* ((node-start (treesit-node-start node))
169 (node-end (treesit-node-end node)) 169 (node-end (treesit-node-end node))
170 (node-text (treesit-node-text node t)) 170 (node-text (treesit-node-text node t))
171 (delimiter-end (+ 2 node-start))) 171 (delimiter-end (progn
172 (goto-char node-start)
173 (while (looking-at-p "-") (forward-char))
174 (point))))
172 (when (and (>= node-start start) 175 (when (and (>= node-start start)
173 (<= delimiter-end end) 176 (<= delimiter-end end)
174 (string-match "\\`--" node-text)) 177 (string-match "\\`---*" node-text))
175 (treesit-fontify-with-override node-start 178 (treesit-fontify-with-override node-start
176 delimiter-end 179 delimiter-end
177 'font-lock-comment-delimiter-face 180 'font-lock-comment-delimiter-face
diff --git a/test/lisp/progmodes/lua-ts-mode-resources/font-lock.lua b/test/lisp/progmodes/lua-ts-mode-resources/font-lock.lua
index 93d589e3825..5a36bcad10b 100644
--- a/test/lisp/progmodes/lua-ts-mode-resources/font-lock.lua
+++ b/test/lisp/progmodes/lua-ts-mode-resources/font-lock.lua
@@ -11,6 +11,11 @@ Multi-line comment
11-- <- font-lock-comment-face 11-- <- font-lock-comment-face
12local line_comment = "comment" -- comment 12local line_comment = "comment" -- comment
13-- ^ font-lock-comment-face 13-- ^ font-lock-comment-face
14---@alias MyNumber integer
15-- <- font-lock-comment-delimiter-face
16------Calculate new number
17-- ^ font-lock-comment-delimiter-face
18function calc() end
14 19
15-- Definition 20-- Definition
16local function f1() end 21local function f1() end