Fix language_js regex/comment distinction (#1731)

This commit is contained in:
Guldoman
2024-03-23 20:28:31 +08:00
committed by takase1121
parent 48aa350a3e
commit ddf08de1d4
+5 -4
View File
@@ -63,12 +63,13 @@ syntax.add {
{ pattern = { '"', '"', '\\' }, type = "string" },
{ pattern = { "'", "'", '\\' }, type = "string" },
{ pattern = { "`", "`", '\\' }, type = "string" },
{ pattern = "-?0[xXbBoO][%da-fA-F_]+n?()%s*()/?", type = {"number", "normal", "operator"} },
{ pattern = "-?%d+[%d%.eE_n]*()%s*()/?", type = {"number", "normal", "operator"} },
{ pattern = "-?%.?%d+()%s*()/?", type = {"number", "normal", "operator"} },
-- Use (?:\/(?!\/))? to avoid that a regex can start after a number, while also allowing // comments
{ regex = [[-?0[xXbBoO][\da-fA-F_]+n?()\s*()(?:\/(?!\/))?]], type = {"number", "normal", "operator"} },
{ regex = [[-?\d+[0-9.eE_n]*()\s*()(?:\/(?!\/))?]], type = {"number", "normal", "operator"} },
{ regex = [[-?\.?\d+()\s*()(?:\/(?!\/))?]], type = {"number", "normal", "operator"} },
{ pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" },
{ pattern = "[%a_][%w_]*%f[(]", type = "function" },
{ pattern = "[%a_][%w_]*()%s*()/?", type = {"symbol", "normal", "operator"} },
{ regex = [=[[a-zA-Z_]\w*()\s*()(?:\/(?!\/))?]=], type = {"symbol", "normal", "operator"} },
},
symbols = {
["async"] = "keyword",