From cada3d82ac415b0104eb9ffecd4f832209c47a63 Mon Sep 17 00:00:00 2001 From: ivanauth Date: Fri, 1 May 2026 14:40:39 -0400 Subject: [PATCH] fix(grammars/zed): style use, with/and expiration, with caveat, partial spread; widen import path regex --- grammars/authzed.tmLanguage.json | 49 ++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/grammars/authzed.tmLanguage.json b/grammars/authzed.tmLanguage.json index a74375ed..d4bc73eb 100644 --- a/grammars/authzed.tmLanguage.json +++ b/grammars/authzed.tmLanguage.json @@ -6,10 +6,15 @@ "foldingStopMarker": "^\\s*\\}", "patterns": [ { "include": "#comment" }, + { "include": "#useDirective" }, { "include": "#importStatement" }, { "include": "#objectDefinition" }, { "include": "#objectRelation" }, { "include": "#objectPermission" }, + { "include": "#withExpiration" }, + { "include": "#andExpiration" }, + { "include": "#withCaveat" }, + { "include": "#partialSpread" }, { "include": "#operator" }, { "include": "#prefix" } ], @@ -202,8 +207,8 @@ "name": "keyword.control.class.authzed" }, "importPath": { - "comment": "a quote-delimited string", - "match": "[\"']\\w+[\"']", + "comment": "a quote-delimited path (allows ./ and . in path segments)", + "match": "[\"']([^\"'\\n]+?)[\"']", "name": "string.quoted" } } @@ -247,6 +252,46 @@ "name": "variable.other.authzed" } } + }, + "useDirective": { + "comment": "use import | use partial | use expiration directive (composable schemas)", + "match": "^\\s*(use)\\s+(import|partial|expiration)\\b", + "captures": { + "1": { "name": "keyword.control.class.authzed" }, + "2": { "name": "keyword.control.class.authzed" } + } + }, + "withExpiration": { + "comment": " with expiration (must be listed before withCaveat so 'expiration' matches as keyword, not as a caveat name)", + "match": "\\b(with)\\s+(expiration)\\b", + "captures": { + "1": { "name": "keyword.control.class.authzed" }, + "2": { "name": "keyword.control.class.authzed" } + } + }, + "andExpiration": { + "comment": " with ttl and expiration (combined expiration syntax)", + "match": "\\b(and)\\s+(expiration)\\b", + "captures": { + "1": { "name": "keyword.control.class.authzed" }, + "2": { "name": "keyword.control.class.authzed" } + } + }, + "withCaveat": { + "comment": " with caveat_name (supports namespaced names like org/caveat_name)", + "match": "\\b(with)\\s+([a-zA-Z_]\\w*(?:\\/[a-zA-Z_]\\w*)?)\\b", + "captures": { + "1": { "name": "keyword.control.class.authzed" }, + "2": { "name": "entity.name.type.class.authzed" } + } + }, + "partialSpread": { + "comment": "partial inclusion expression: ...partial_name (lookbehind prevents matching mid-token like foo...bar or after extra dots)", + "match": "(?