1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-04 11:00:45 -08:00

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)
This commit is contained in:
john muhl 2025-05-14 08:53:42 -05:00 committed by Eli Zaretskii
parent b0efe06551
commit 34f3ac6c5b
2 changed files with 10 additions and 2 deletions

View file

@ -168,10 +168,13 @@ values of OVERRIDE."
(let* ((node-start (treesit-node-start node)) (let* ((node-start (treesit-node-start node))
(node-end (treesit-node-end node)) (node-end (treesit-node-end node))
(node-text (treesit-node-text node t)) (node-text (treesit-node-text node t))
(delimiter-end (+ 2 node-start))) (delimiter-end (progn
(goto-char node-start)
(while (looking-at-p "-") (forward-char))
(point))))
(when (and (>= node-start start) (when (and (>= node-start start)
(<= delimiter-end end) (<= delimiter-end end)
(string-match "\\`--" node-text)) (string-match "\\`---*" node-text))
(treesit-fontify-with-override node-start (treesit-fontify-with-override node-start
delimiter-end delimiter-end
'font-lock-comment-delimiter-face 'font-lock-comment-delimiter-face

View file

@ -11,6 +11,11 @@ Multi-line comment
-- <- font-lock-comment-face -- <- font-lock-comment-face
local line_comment = "comment" -- comment local line_comment = "comment" -- comment
-- ^ font-lock-comment-face -- ^ font-lock-comment-face
---@alias MyNumber integer
-- <- font-lock-comment-delimiter-face
------Calculate new number
-- ^ font-lock-comment-delimiter-face
function calc() end
-- Definition -- Definition
local function f1() end local function f1() end