From 00cd37a1dd2b36b190c7c3c61e2f7400a92220e0 Mon Sep 17 00:00:00 2001 From: Jeff Martin Date: Sat, 14 Nov 2026 12:04:10 -0800 Subject: [PATCH 1/3] Add syntax highlighting for the Actions lockfile Registers a GitHub Actions Lockfile language for .github/workflows/actions.lock that reuses the bundled YAML grammar and injects scopes for action pins (owner/repo@ref) and commit digests. --- README.md | 2 + language/syntaxes/lockfile.tmGrammar.json | 49 ++++++++++++++++++++++ language/syntaxes/lockfile.tmLanguage.json | 9 ++++ package.json | 26 ++++++++++++ 4 files changed, 86 insertions(+) create mode 100644 language/syntaxes/lockfile.tmGrammar.json create mode 100644 language/syntaxes/lockfile.tmLanguage.json diff --git a/README.md b/README.md index 8b257498..82cabf1b 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ Be more confident when authoring and modifying workflows. Find errors before com ![Syntax highlighting](media/highlight.png) +The Actions dependency lockfile (`.github/workflows/actions.lock`, written by `gh actions-lock`) is highlighted too, with action pins (`owner/repo@ref`) and commit digests called out. + **Integrated documentation** for the workflow schema, expression functions, and even event payloads: ![Tooltip showing description for a pull_request payload](media/docs.png) diff --git a/language/syntaxes/lockfile.tmGrammar.json b/language/syntaxes/lockfile.tmGrammar.json new file mode 100644 index 00000000..7b352258 --- /dev/null +++ b/language/syntaxes/lockfile.tmGrammar.json @@ -0,0 +1,49 @@ +{ + "scopeName": "source.github-actions-lockfile.pins", + "injectionSelector": "L:source.github-actions-lockfile -comment", + "patterns": [ + { + "include": "#commit" + }, + { + "include": "#pin" + } + ], + "repository": { + "commit": { + "match": "(? Date: Wed, 25 Nov 2026 13:59:40 -0800 Subject: [PATCH 2/3] Drop the README line for lockfile highlighting --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 82cabf1b..8b257498 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,6 @@ Be more confident when authoring and modifying workflows. Find errors before com ![Syntax highlighting](media/highlight.png) -The Actions dependency lockfile (`.github/workflows/actions.lock`, written by `gh actions-lock`) is highlighted too, with action pins (`owner/repo@ref`) and commit digests called out. - **Integrated documentation** for the workflow schema, expression functions, and even event payloads: ![Tooltip showing description for a pull_request payload](media/docs.png) From eb3ce9904732eac4d0a246547cae37e984ac4c86 Mon Sep 17 00:00:00 2001 From: Jeff Martin Date: Wed, 25 Nov 2026 14:24:39 -0800 Subject: [PATCH 3/3] Highlight lockfile refs that contain # or , Git refs may contain # and ,. Quoted pins now color the whole ref. Plain pins keep # (YAML only starts a comment after whitespace) but still stop at , so flow sequences split correctly. --- language/syntaxes/lockfile.tmGrammar.json | 33 +++++++++++++++- src/lockfileGrammar.test.ts | 46 +++++++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 src/lockfileGrammar.test.ts diff --git a/language/syntaxes/lockfile.tmGrammar.json b/language/syntaxes/lockfile.tmGrammar.json index 7b352258..febc9a71 100644 --- a/language/syntaxes/lockfile.tmGrammar.json +++ b/language/syntaxes/lockfile.tmGrammar.json @@ -25,7 +25,38 @@ } }, "pin": { - "match": "(?}; + +const pinRules = (grammar.repository.pin.patterns ?? []).map( + p => new RegExp(grammar.repository[p.include.slice(1)].match ?? "", "g") +); + +// Mirrors TextMate scanning: at each position the earliest match wins, ties go to the first rule. +function refs(line: string): string[] { + const found: string[] = []; + let pos = 0; + for (;;) { + let best: RegExpExecArray | null = null; + for (const re of pinRules) { + re.lastIndex = pos; + const m = re.exec(line); + if (m && (!best || m.index < best.index)) best = m; + } + if (!best) return found; + found.push(best[5]); + pos = best.index + best[0].length; + } +} + +describe("lockfile pin grammar", () => { + it("captures the full ref in quoted entries, including # and ,", () => { + expect(refs(" - 'actions/checkout@release#1'")).toEqual(["release#1"]); + expect(refs(' - "actions/checkout@release,1"')).toEqual(["release,1"]); + expect(refs(" 'actions/checkout@feature/x#2,3':")).toEqual(["feature/x#2,3"]); + }); + + it("keeps # in plain refs but stops at comments and flow separators", () => { + expect(refs(" - actions/checkout@release#1 # note")).toEqual(["release#1"]); + expect(refs(" - [actions/checkout@v1, actions/setup-node@v2]")).toEqual(["v1", "v2"]); + }); + + it("does not run past the closing quote", () => { + expect(refs(" 'actions/checkout@v4':")).toEqual(["v4"]); + }); +});