From 8887757acb2d00103ec945bf74504adb0335f910 Mon Sep 17 00:00:00 2001 From: aaronvg Date: Fri, 25 Oct 2024 17:32:21 -0700 Subject: [PATCH] syntax highlight vscode (#1105) > [!IMPORTANT] > Add syntax highlighting for `@check` and `@assert` attributes in BAML files for VSCode. > > - **Syntax Highlighting**: > - Add new patterns for `@check` and `@assert` attributes in `baml.tmLanguage.json`. > - Handles both single and double `@` prefixes. > - Captures function names and parameters for these attributes. > > This description was created by [Ellipsis](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral) for 962c428b7600d35d9e4d979f861878c6f9a48484. It will automatically update as commits are pushed. --- .../packages/syntaxes/baml.tmLanguage.json | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/typescript/vscode-ext/packages/syntaxes/baml.tmLanguage.json b/typescript/vscode-ext/packages/syntaxes/baml.tmLanguage.json index 72d7e196a..4a618bb03 100644 --- a/typescript/vscode-ext/packages/syntaxes/baml.tmLanguage.json +++ b/typescript/vscode-ext/packages/syntaxes/baml.tmLanguage.json @@ -325,6 +325,33 @@ }, "block_attribute": { "patterns": [ + { + "begin": "(@{1,2}(?:check|assert))\\(([^,]+)?\\s*,\\s*()", + "beginCaptures": { + "1": { "name": "entity.name.function.attribute" }, + "2": { "name": "variable.parameter.checkName" }, + "3": { "name": "punctuation.definition.template-expression.begin" } + }, + "end": "()\\)", + "endCaptures": { + "1": { "name": "punctuation.definition.template-expression.end" } + }, + "contentName": "string.quoted.block.thing", + "patterns": [{ "include": "source.baml-jinja" }] + }, + { + "begin": "(@{1,2}assert)\\(", + "beginCaptures": { + "1": { "name": "entity.name.function.attribute.assert" }, + "2": { "name": "punctuation.definition.template-expression.begin" } + }, + "end": "()\\)", + "endCaptures": { + "1": { "name": "punctuation.definition.template-expression.end" } + }, + "contentName": "string.quoted.block.thing", + "patterns": [{ "include": "source.baml-jinja" }] + }, { "begin": "(@{1,2}\\w+)\\(#\"", "beginCaptures": {