feat(editor): add Prism grammar for Source-engine .cfg syntax

Five token classes (comment, string, keyword, number, identifier) plus
operators. Purely visual highlighting; no semantic validation of cvar
names or values.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
mwiegand 2026-05-16 19:11:56 +02:00
parent 4a1b6d5fac
commit 7cfbedb929
No known key found for this signature in database

View file

@ -0,0 +1,17 @@
// Prism grammar for Source-engine config files (server.cfg-style).
// Tokens: comment, string, number, keyword, identifier. Purely visual —
// no semantic validation of cvars or values.
(function (Prism) {
if (!Prism) return;
Prism.languages.srccfg = {
comment: /\/\/.*/,
string: {
pattern: /"(?:\\.|[^"\\])*"/,
greedy: true,
},
keyword: /\b(?:exec|alias|bind|unbind|toggle)\b/,
number: /\b-?\d+(?:\.\d+)?\b/,
identifier: /\b[a-zA-Z_][a-zA-Z0-9_]*\b/,
operator: /[+\-;]/,
};
})(typeof window !== "undefined" ? window.Prism : undefined);