From 0553d5f165637fac345da868a23e4ae2adc1499e Mon Sep 17 00:00:00 2001
From: oli-ej <11294502+oli-ej@users.noreply.github.com>
Date: Mon, 20 Jul 2026 23:37:37 +0100
Subject: [PATCH] Update Textmate for types in a list and add `unused` keyword
(#7535)
Setting "type" to bright red to make comparison obvious:
(screenshots taken from VSCode)
Before
After
I'm not super familiar with textmate/highlightjs, but I think what was
happening on line 5 is that the "type" scope is being extended to the
`=` after `.y`.
Adding `,` as an "end" token fixes this, and I think this is what
highlightjs already does.
I've also added "unused" as a keyword.
---
utils/highlightjs/highlightjs_carbon_lang.js | 1 +
utils/textmate/Syntaxes/carbon.tmLanguage | 4 ++--
utils/vscode/carbon.tmLanguage.json | 4 ++--
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/utils/highlightjs/highlightjs_carbon_lang.js b/utils/highlightjs/highlightjs_carbon_lang.js
index 090762f8bd56..2c1b355bb031 100644
--- a/utils/highlightjs/highlightjs_carbon_lang.js
+++ b/utils/highlightjs/highlightjs_carbon_lang.js
@@ -72,6 +72,7 @@ export default function (hljs) {
'then',
'type',
'_',
+ 'unused',
'var',
'virtual',
'where',
diff --git a/utils/textmate/Syntaxes/carbon.tmLanguage b/utils/textmate/Syntaxes/carbon.tmLanguage
index c6f90f745935..cb5a7ffc2a07 100644
--- a/utils/textmate/Syntaxes/carbon.tmLanguage
+++ b/utils/textmate/Syntaxes/carbon.tmLanguage
@@ -607,7 +607,7 @@ THIS FILE IS AUTOGENERATED FROM carbon.tmLanguage.json. DO NOT EDIT.
match
- \b(and|as|generic|impls|in|like|not|or|partial|ref|runtime|template|where)\b
+ \b(and|as|generic|impls|in|like|not|or|partial|ref|runtime|template|unused|where)\b
name
keyword.control.carbon
@@ -801,7 +801,7 @@ THIS FILE IS AUTOGENERATED FROM carbon.tmLanguage.json. DO NOT EDIT.
comment
Matches types in bindings.
end
- (?=([;{=]|->|in|where))
+ (?=([;{=,]|->|in|where))
patterns
diff --git a/utils/vscode/carbon.tmLanguage.json b/utils/vscode/carbon.tmLanguage.json
index db2ac7c7a7b6..4f1bacad41c8 100644
--- a/utils/vscode/carbon.tmLanguage.json
+++ b/utils/vscode/carbon.tmLanguage.json
@@ -227,7 +227,7 @@
{
"comment": "Matches types in bindings.",
"begin": ":",
- "end": "(?=([;{=]|->|in|where))",
+ "end": "(?=([;{=,]|->|in|where))",
"patterns": [
{ "include": "#common" },
{ "include": "#variables" },
@@ -346,7 +346,7 @@
},
{
"name": "keyword.control.carbon",
- "match": "\\b(and|as|generic|impls|in|like|not|or|partial|ref|runtime|template|where)\\b"
+ "match": "\\b(and|as|generic|impls|in|like|not|or|partial|ref|runtime|template|unused|where)\\b"
}
]
},