diff --git a/crates/tinymist-query/src/hover.rs b/crates/tinymist-query/src/hover.rs index 57c39df6..5783366f 100644 --- a/crates/tinymist-query/src/hover.rs +++ b/crates/tinymist-query/src/hover.rs @@ -61,8 +61,8 @@ fn def_tooltip(ctx: &mut AnalysisContext, source: &Source, cursor: usize) -> Opt crate::syntax::LexicalKind::Var(LexicalVarKind::Function) => { let f = lnk.value.as_ref(); Some(Tooltip::Text(eco_format!( - r#"```typc -let {}({}); + r#"```typst-grammar +#let {}({}); ```{}"#, lnk.name, ParamTooltip(f), @@ -80,8 +80,8 @@ let {}({}); Some(Tooltip::Text(eco_format!( r#" -```typc -let {}; +```typst-grammar +#let {}; ```{v}"#, lnk.name ))) diff --git a/editors/vscode/package.json b/editors/vscode/package.json index 5bf464bb..0a397660 100644 --- a/editors/vscode/package.json +++ b/editors/vscode/package.json @@ -157,6 +157,24 @@ "light": "./icons/typst-small.png", "dark": "./icons/typst-small.png" } + }, + { + "id": "typst-grammar", + "aliases": [ + "Typst with Syntax Support" + ], + "configuration": "./language-configuration.json", + "icon": { + "light": "./icons/typst-small.png", + "dark": "./icons/typst-small.png" + } + } + ], + "grammars": [ + { + "language": "typst-grammar", + "scopeName": "source.typst-grammar", + "path": "./out/typst.tmLanguage.json" } ], "semanticTokenTypes": [ @@ -369,10 +387,11 @@ ], "scripts": { "build:frontend": "cd ../../tools/editor-tools/ && yarn run build", + "build:syntax": "cd ../../syntaxes/textmate && yarn run compile && yarn run bundle", "build-base": "esbuild ./src/extension.ts --bundle --outfile=out/extension.js --external:vscode --format=cjs --platform=node --target=node16", "vscode:prepublish": "yarn run build-base -- --minify && yarn run build:frontend && node scripts/postinstall.cjs", "package": "vsce package --yarn", - "compile": "yarn run build-base -- --sourcemap && yarn run build:frontend && node scripts/postinstall.cjs", + "compile": "yarn run build-base -- --sourcemap && yarn run build:syntax && yarn run build:frontend && node scripts/postinstall.cjs", "watch": "yarn run build-base -- --sourcemap --watch", "check": "tsc --noEmit", "lint": "eslint ./src --ext .ts", diff --git a/syntaxes/textmate/.gitignore b/syntaxes/textmate/.gitignore new file mode 100644 index 00000000..7483f4ee --- /dev/null +++ b/syntaxes/textmate/.gitignore @@ -0,0 +1 @@ +*.tmLanguage.json \ No newline at end of file diff --git a/syntaxes/textmate/package.json b/syntaxes/textmate/package.json new file mode 100644 index 00000000..9e8becbf --- /dev/null +++ b/syntaxes/textmate/package.json @@ -0,0 +1,32 @@ +{ + "name": "typst-textmate", + "version": "0.11.0", + "private": true, + "scripts": { + "compile": "js-yaml typst.tmLanguage.yaml > typst.tmLanguage.json", + "bundle": "node scripts/install.cjs", + "test": "yarn compile && npx vscode-tmgrammar-snap --updateSnapshot tests/unit/**/*.typ" + }, + "devDependencies": { + "js-yaml": "^4.1.0", + "vscode-tmgrammar-test": "^0.1.3" + }, + "contributes": { + "languages": [ + { + "id": "typst", + "extensions": [ + ".typ", + ".typc" + ] + } + ], + "grammars": [ + { + "language": "typst", + "scopeName": "source.typst", + "path": "./typst.tmLanguage.json" + } + ] + } +} diff --git a/syntaxes/textmate/scripts/install.cjs b/syntaxes/textmate/scripts/install.cjs new file mode 100644 index 00000000..aa15ca2f --- /dev/null +++ b/syntaxes/textmate/scripts/install.cjs @@ -0,0 +1,25 @@ +// read typst.tmLanguage.json + +const fs = require("fs"); +const path = require("path"); + +const filePath = path.join(__dirname, "../typst.tmLanguage.json"); + +const data = fs.readFileSync(filePath, "utf8"); + +const json = JSON.parse(data); + +json.scopeName = "source.typst-grammar"; +json.name = "typst-grammar"; +// todo: make it back when we finished +// json.repository.fenced_code_block_typst.patterns = [ +// { include: "source.typst-grammar" } +// ]; +delete json.repository.fenced_code_block_typst.patterns; + +const outPath = path.join( + __dirname, + "../../../editors/vscode/out/typst.tmLanguage.json" +); + +fs.writeFileSync(outPath, JSON.stringify(json, null, 4), "utf8"); diff --git a/syntaxes/textmate/tests/unit/basic/array.typ b/syntaxes/textmate/tests/unit/basic/array.typ new file mode 100644 index 00000000..eb238fd6 --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/array.typ @@ -0,0 +1,6 @@ +#(0) +#let f(name) = ( + ( + pad(align(center + horizon, name)), + ), +) \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/basic/array.typ.snap b/syntaxes/textmate/tests/unit/basic/array.typ.snap new file mode 100644 index 00000000..02cd9deb --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/array.typ.snap @@ -0,0 +1,44 @@ +>#(0) +#^ source.typst punctuation.definition.hash.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst meta.brace.round.typst +>#let f(name) = ( +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst meta.expr.let.typst storage.type.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst entity.name.function.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^^^^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst keyword.operator.assignment.typst +# ^ source.typst +# ^ source.typst meta.brace.round.typst +> ( +#^^ source.typst +# ^ source.typst meta.brace.round.typst +> pad(align(center + horizon, name)), +#^^^^ source.typst +# ^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^^^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^^^^^^ source.typst variable.other.readwrite.typst +# ^ source.typst +# ^ source.typst keyword.operator.arithmetic.typst +# ^ source.typst +# ^^^^^^^ source.typst variable.other.readwrite.typst +# ^ source.typst punctuation.separator.comma.typst +# ^ source.typst +# ^^^^ source.typst variable.other.readwrite.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst punctuation.separator.comma.typst +# ^^ source.typst +> ), +#^^ source.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst punctuation.separator.comma.typst +>) +#^ source.typst meta.brace.round.typst \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/basic/block.typ b/syntaxes/textmate/tests/unit/basic/block.typ new file mode 100644 index 00000000..1ecd5912 --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/block.typ @@ -0,0 +1,3 @@ +#{ + +} \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/basic/block.typ.snap b/syntaxes/textmate/tests/unit/basic/block.typ.snap new file mode 100644 index 00000000..da15edab --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/block.typ.snap @@ -0,0 +1,6 @@ +>#{ +#^ source.typst punctuation.definition.hash.typst +# ^ source.typst meta.brace.curly.typst +> +>} +#^ source.typst meta.brace.curly.typst \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/basic/call.typ b/syntaxes/textmate/tests/unit/basic/call.typ new file mode 100644 index 00000000..28f53b71 --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/call.typ @@ -0,0 +1,4 @@ +#text +#我们 +#text("//") +#calc.rem(1, 1) diff --git a/syntaxes/textmate/tests/unit/basic/call.typ.snap b/syntaxes/textmate/tests/unit/basic/call.typ.snap new file mode 100644 index 00000000..3976b5c9 --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/call.typ.snap @@ -0,0 +1,26 @@ +>#text +#^ source.typst punctuation.definition.hash.typst +# ^^^^ source.typst variable.other.readwrite.typst +>#我们 +#^ source.typst punctuation.definition.hash.typst +# ^^ source.typst variable.other.readwrite.typst +>#text("//") +#^ source.typst punctuation.definition.hash.typst +# ^^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^^ source.typst string.quoted.double.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^ source.typst meta.brace.round.typst +>#calc.rem(1, 1) +#^ source.typst punctuation.definition.hash.typst +# ^^^^ source.typst variable.other.readwrite.typst +# ^ source.typst keyword.operator.accessor.typst +# ^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst punctuation.separator.comma.typst +# ^ source.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst meta.brace.round.typst +> \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/basic/control-flow-for.typ b/syntaxes/textmate/tests/unit/basic/control-flow-for.typ new file mode 100644 index 00000000..bf26049a --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/control-flow-for.typ @@ -0,0 +1,15 @@ +#for i +#for i in +#for i in range(1) +#for i in range(1) {} +#for i in {} +#for i in {}; 1 +#for i in range(1) {}; 1 +#for i in range(1) {}1 +#for i in range(1) {}a +#for i in range(1) {} 1 +#for i in range(1) {} a +#for i in range(1) {} +#for i in range(1) {}; {} +#for i in range(1) {} {} +1 \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/basic/control-flow-for.typ.snap b/syntaxes/textmate/tests/unit/basic/control-flow-for.typ.snap new file mode 100644 index 00000000..f414ea78 --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/control-flow-for.typ.snap @@ -0,0 +1,193 @@ +>#for i +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst keyword.control.loop.typst +# ^^ source.typst +>#for i in +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst keyword.control.loop.typst +# ^ source.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst +# ^^ source.typst keyword.other.typst +>#for i in range(1) +#^ source.typst +# ^^^ source.typst keyword.control.loop.typst +# ^ source.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst +# ^^ source.typst keyword.other.typst +# ^ source.typst +# ^^^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst meta.brace.round.typst +>#for i in range(1) {} +#^ source.typst +# ^^^ source.typst keyword.control.loop.typst +# ^ source.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst +# ^^ source.typst keyword.other.typst +# ^ source.typst +# ^^^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +>#for i in {} +#^ source.typst +# ^^^ source.typst keyword.control.loop.typst +# ^ source.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst +# ^^ source.typst keyword.other.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +>#for i in {}; 1 +#^ source.typst +# ^^^ source.typst keyword.control.loop.typst +# ^ source.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst +# ^^ source.typst keyword.other.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst punctuation.terminator.statement.typst +# ^^^ source.typst +>#for i in range(1) {}; 1 +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst keyword.control.loop.typst +# ^ source.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst +# ^^ source.typst keyword.other.typst +# ^ source.typst +# ^^^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst punctuation.terminator.statement.typst +# ^^^ source.typst +>#for i in range(1) {}1 +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst keyword.control.loop.typst +# ^ source.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst +# ^^ source.typst keyword.other.typst +# ^ source.typst +# ^^^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst +>#for i in range(1) {}a +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst keyword.control.loop.typst +# ^ source.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst +# ^^ source.typst keyword.other.typst +# ^ source.typst +# ^^^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst +>#for i in range(1) {} 1 +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst keyword.control.loop.typst +# ^ source.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst +# ^^ source.typst keyword.other.typst +# ^ source.typst +# ^^^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +# ^^ source.typst +>#for i in range(1) {} a +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst keyword.control.loop.typst +# ^ source.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst +# ^^ source.typst keyword.other.typst +# ^ source.typst +# ^^^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +# ^^ source.typst +>#for i in range(1) {} +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst keyword.control.loop.typst +# ^ source.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst +# ^^ source.typst keyword.other.typst +# ^ source.typst +# ^^^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +>#for i in range(1) {}; {} +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst keyword.control.loop.typst +# ^ source.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst +# ^^ source.typst keyword.other.typst +# ^ source.typst +# ^^^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst punctuation.terminator.statement.typst +# ^^^^ source.typst +>#for i in range(1) {} {} +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst keyword.control.loop.typst +# ^ source.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst +# ^^ source.typst keyword.other.typst +# ^ source.typst +# ^^^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +>1 +#^^ source.typst \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/basic/control-flow-if.typ b/syntaxes/textmate/tests/unit/basic/control-flow-if.typ new file mode 100644 index 00000000..c5b9d116 --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/control-flow-if.typ @@ -0,0 +1,22 @@ +#if 1 +#if {} 1 +#if {} else {} 1 +#if 1 {} else {} 1 +#if [] {} else {} #1 +#if {} {} else {} {} +#if () {} else {} # a + +#if () {} else {} +1 + +#if () {} else {} +{} + +#if () {} else {} +{ +#if () {} else {} + + +1 +# if () {} else {} +1 diff --git a/syntaxes/textmate/tests/unit/basic/control-flow-if.typ.snap b/syntaxes/textmate/tests/unit/basic/control-flow-if.typ.snap new file mode 100644 index 00000000..0408ff97 --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/control-flow-if.typ.snap @@ -0,0 +1,161 @@ +>#if 1 +#^ source.typst punctuation.definition.hash.typst +# ^^ source.typst keyword.control.conditional.typst +# ^ source.typst +# ^ source.typst constant.numeric.integer.typst +>#if {} 1 +#^ source.typst punctuation.definition.hash.typst +# ^^ source.typst keyword.control.conditional.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst +# ^ source.typst constant.numeric.integer.typst +>#if {} else {} 1 +#^ source.typst punctuation.definition.hash.typst +# ^^ source.typst keyword.control.conditional.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst +# ^^^^ source.typst variable.other.readwrite.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst +# ^ source.typst constant.numeric.integer.typst +>#if 1 {} else {} 1 +#^ source.typst punctuation.definition.hash.typst +# ^^ source.typst keyword.control.conditional.typst +# ^ source.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst +# ^^^^ source.typst variable.other.readwrite.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst +# ^ source.typst constant.numeric.integer.typst +>#if [] {} else {} #1 +#^ source.typst punctuation.definition.hash.typst +# ^^ source.typst keyword.control.conditional.typst +# ^ source.typst +# ^ source.typst meta.brace.square.typ +# ^ source.typst meta.brace.square.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst +# ^^^^ source.typst variable.other.readwrite.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +# ^^ source.typst +# ^ source.typst constant.numeric.integer.typst +>#if {} {} else {} {} +#^ source.typst punctuation.definition.hash.typst +# ^^ source.typst keyword.control.conditional.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst +# ^^^^ source.typst variable.other.readwrite.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +>#if () {} else {} # a +#^ source.typst punctuation.definition.hash.typst +# ^^ source.typst keyword.control.conditional.typst +# ^ source.typst +# ^^ source.typst meta.array.empty.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst +# ^^^^ source.typst variable.other.readwrite.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +# ^^^ source.typst +# ^ source.typst variable.other.readwrite.typst +> +>#if () {} else {} +#^ source.typst punctuation.definition.hash.typst +# ^^ source.typst keyword.control.conditional.typst +# ^ source.typst +# ^^ source.typst meta.array.empty.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst +# ^^^^ source.typst variable.other.readwrite.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +>1 +#^^ source.typst +> +>#if () {} else {} +#^ source.typst punctuation.definition.hash.typst +# ^^ source.typst keyword.control.conditional.typst +# ^ source.typst +# ^^ source.typst meta.array.empty.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst +# ^^^^ source.typst variable.other.readwrite.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +>{} +#^^^ source.typst +> +>#if () {} else {} +#^ source.typst punctuation.definition.hash.typst +# ^^ source.typst keyword.control.conditional.typst +# ^ source.typst +# ^^ source.typst meta.array.empty.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst +# ^^^^ source.typst variable.other.readwrite.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +>{ +#^^ source.typst +>#if () {} else {} +#^ source.typst punctuation.definition.hash.typst +# ^^ source.typst keyword.control.conditional.typst +# ^ source.typst +# ^^ source.typst meta.array.empty.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst +# ^^^^ source.typst variable.other.readwrite.typst +# ^ source.typst +# ^ source.typst meta.brace.curly.typst +# ^ source.typst meta.brace.curly.typst +> +> +>1 +#^^ source.typst +># if () {} else {} +#^ source.typst punctuation.definition.hash.typst +# ^ source.typst +# ^^^^^^^^^^^^^^^^^ source.typst +>1 +#^^ source.typst +> \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/basic/expr_lit.typ b/syntaxes/textmate/tests/unit/basic/expr_lit.typ new file mode 100644 index 00000000..2bd23e34 --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/expr_lit.typ @@ -0,0 +1,4 @@ +#() +#( ) +#(:) +#( : ) \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/basic/expr_lit.typ.snap b/syntaxes/textmate/tests/unit/basic/expr_lit.typ.snap new file mode 100644 index 00000000..3c448141 --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/expr_lit.typ.snap @@ -0,0 +1,12 @@ +>#() +#^ source.typst punctuation.definition.hash.typst +# ^^ source.typst meta.array.empty.typst +>#( ) +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst meta.array.empty.typst +>#(:) +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst meta.dictionary.empty.typst +>#( : ) +#^ source.typst punctuation.definition.hash.typst +# ^^^^^ source.typst meta.dictionary.empty.typst \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/basic/http.typ b/syntaxes/textmate/tests/unit/basic/http.typ new file mode 100644 index 00000000..2614e8d8 --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/http.typ @@ -0,0 +1 @@ +https://zh.wikipedia.org \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/basic/http.typ.snap b/syntaxes/textmate/tests/unit/basic/http.typ.snap new file mode 100644 index 00000000..17bf9b4d --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/http.typ.snap @@ -0,0 +1,2 @@ +>https://zh.wikipedia.org +#^^^^^^^^^^^^^^^^^^^^^^^^ source.typst markup.underline.link.typst \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/basic/let.typ b/syntaxes/textmate/tests/unit/basic/let.typ new file mode 100644 index 00000000..617a7ff7 --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/let.typ @@ -0,0 +1,13 @@ +#let x = 1; +#let (x) = 1; +#let (x, y) = (1, 1); +#let (x, (y, z)) = (1, (1, 1)); +#let (a: a) = (a: 1); +#let (a, (b: b)) = (1, (b: 1)); +#let (a, (b: (c, (b: b)))) = (a, (b: (1, (b: b)))); +#let ((b: (c, (b: b))), a) = ((b: (1, (b: b))), a); +#let (a, ..) = (1, 1); +#let (.., a) = (1, 1); +#let (a: a, ..) = (a: a); +#let (.., a: a) = (a: a); +#let (a: a, .., b: b) = (a: a, b: b); \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/basic/let.typ.snap b/syntaxes/textmate/tests/unit/basic/let.typ.snap new file mode 100644 index 00000000..d2a9ab3c --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/let.typ.snap @@ -0,0 +1,343 @@ +>#let x = 1; +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst meta.expr.let.typst storage.type.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst keyword.operator.assignment.typst +# ^ source.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst punctuation.terminator.statement.typst +>#let (x) = 1; +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst meta.expr.let.typst storage.type.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst keyword.operator.assignment.typst +# ^ source.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst punctuation.terminator.statement.typst +>#let (x, y) = (1, 1); +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst meta.expr.let.typst storage.type.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.comma.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst keyword.operator.assignment.typst +# ^ source.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst punctuation.separator.comma.typst +# ^ source.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst punctuation.terminator.statement.typst +>#let (x, (y, z)) = (1, (1, 1)); +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst meta.expr.let.typst storage.type.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.comma.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.comma.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst keyword.operator.assignment.typst +# ^ source.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst punctuation.separator.comma.typst +# ^ source.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst punctuation.separator.comma.typst +# ^ source.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst punctuation.terminator.statement.typst +>#let (a: a) = (a: 1); +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst meta.expr.let.typst storage.type.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.colon.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst keyword.operator.assignment.typst +# ^ source.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst punctuation.separator.colon.typst +# ^ source.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst punctuation.terminator.statement.typst +>#let (a, (b: b)) = (1, (b: 1)); +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst meta.expr.let.typst storage.type.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.comma.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.colon.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst keyword.operator.assignment.typst +# ^ source.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst punctuation.separator.comma.typst +# ^ source.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst punctuation.separator.colon.typst +# ^ source.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst punctuation.terminator.statement.typst +>#let (a, (b: (c, (b: b)))) = (a, (b: (1, (b: b)))); +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst meta.expr.let.typst storage.type.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.comma.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.colon.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.comma.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.colon.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst keyword.operator.assignment.typst +# ^ source.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst punctuation.separator.comma.typst +# ^ source.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst punctuation.separator.colon.typst +# ^ source.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst punctuation.separator.comma.typst +# ^ source.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst punctuation.separator.colon.typst +# ^ source.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst punctuation.terminator.statement.typst +>#let ((b: (c, (b: b))), a) = ((b: (1, (b: b))), a); +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst meta.expr.let.typst storage.type.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.colon.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.comma.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.colon.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.comma.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst keyword.operator.assignment.typst +# ^ source.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst punctuation.separator.colon.typst +# ^ source.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst punctuation.separator.comma.typst +# ^ source.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst punctuation.separator.colon.typst +# ^ source.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst punctuation.separator.comma.typst +# ^ source.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst punctuation.terminator.statement.typst +>#let (a, ..) = (1, 1); +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst meta.expr.let.typst storage.type.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.comma.typst +# ^ source.typst meta.expr.let.typst +# ^^ source.typst meta.expr.let.typst keyword.operator.range.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst keyword.operator.assignment.typst +# ^ source.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst punctuation.separator.comma.typst +# ^ source.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst punctuation.terminator.statement.typst +>#let (.., a) = (1, 1); +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst meta.expr.let.typst storage.type.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^^ source.typst meta.expr.let.typst keyword.operator.range.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.comma.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst keyword.operator.assignment.typst +# ^ source.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst punctuation.separator.comma.typst +# ^ source.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst punctuation.terminator.statement.typst +>#let (a: a, ..) = (a: a); +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst meta.expr.let.typst storage.type.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.colon.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.comma.typst +# ^ source.typst meta.expr.let.typst +# ^^ source.typst meta.expr.let.typst keyword.operator.range.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst keyword.operator.assignment.typst +# ^ source.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst punctuation.separator.colon.typst +# ^ source.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst punctuation.terminator.statement.typst +>#let (.., a: a) = (a: a); +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst meta.expr.let.typst storage.type.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^^ source.typst meta.expr.let.typst keyword.operator.range.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.comma.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.colon.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst keyword.operator.assignment.typst +# ^ source.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst punctuation.separator.colon.typst +# ^ source.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst punctuation.terminator.statement.typst +>#let (a: a, .., b: b) = (a: a, b: b); +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst meta.expr.let.typst storage.type.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.colon.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.comma.typst +# ^ source.typst meta.expr.let.typst +# ^^ source.typst meta.expr.let.typst keyword.operator.range.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.comma.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.colon.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst keyword.operator.assignment.typst +# ^ source.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst punctuation.separator.colon.typst +# ^ source.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst punctuation.separator.comma.typst +# ^ source.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst punctuation.separator.colon.typst +# ^ source.typst +# ^ source.typst variable.other.readwrite.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst punctuation.terminator.statement.typst \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/basic/let2.typ b/syntaxes/textmate/tests/unit/basic/let2.typ new file mode 100644 index 00000000..6eaf5218 --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/let2.typ @@ -0,0 +1,4 @@ +#(let x = 1) +#(let x = 1); +#(((let x = 1))); +#(((let x = 1))) \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/basic/let2.typ.snap b/syntaxes/textmate/tests/unit/basic/let2.typ.snap new file mode 100644 index 00000000..5fe18a05 --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/let2.typ.snap @@ -0,0 +1,54 @@ +>#(let x = 1) +#^ source.typst punctuation.definition.hash.typst +# ^ source.typst meta.brace.round.typst +# ^^^ source.typst meta.expr.let.typst storage.type.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst keyword.operator.assignment.typst +# ^ source.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst meta.brace.round.typst +>#(let x = 1); +#^ source.typst punctuation.definition.hash.typst +# ^ source.typst meta.brace.round.typst +# ^^^ source.typst meta.expr.let.typst storage.type.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst keyword.operator.assignment.typst +# ^ source.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst punctuation.terminator.statement.typst +>#(((let x = 1))); +#^ source.typst punctuation.definition.hash.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst meta.brace.round.typst +# ^^^ source.typst meta.expr.let.typst storage.type.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst keyword.operator.assignment.typst +# ^ source.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst punctuation.terminator.statement.typst +>#(((let x = 1))) +#^ source.typst punctuation.definition.hash.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst meta.brace.round.typst +# ^^^ source.typst meta.expr.let.typst storage.type.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst keyword.operator.assignment.typst +# ^ source.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst meta.brace.round.typst \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/basic/let_fn.typ b/syntaxes/textmate/tests/unit/basic/let_fn.typ new file mode 100644 index 00000000..6c8297fe --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/let_fn.typ @@ -0,0 +1,9 @@ +#let f() = 1; +#let f(a) = 1; +#let f(a, b: none) = 1; +#let f(a, (b, c)) = 1; +#let f(a, (b, c: d)) = 1; +#let f((a, b)) = 1; +#let f((a, (c: (b: e)))) = 1; +#let f((a, ..)) = 1; +#let f((.., a)) = 1; \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/basic/let_fn.typ.snap b/syntaxes/textmate/tests/unit/basic/let_fn.typ.snap new file mode 100644 index 00000000..ecd770f4 --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/let_fn.typ.snap @@ -0,0 +1,171 @@ +>#let f() = 1; +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst meta.expr.let.typst storage.type.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst entity.name.function.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst keyword.operator.assignment.typst +# ^ source.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst punctuation.terminator.statement.typst +>#let f(a) = 1; +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst meta.expr.let.typst storage.type.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst entity.name.function.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst keyword.operator.assignment.typst +# ^ source.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst punctuation.terminator.statement.typst +>#let f(a, b: none) = 1; +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst meta.expr.let.typst storage.type.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst entity.name.function.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.comma.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.colon.typst +# ^ source.typst meta.expr.let.typst +# ^^^^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst keyword.operator.assignment.typst +# ^ source.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst punctuation.terminator.statement.typst +>#let f(a, (b, c)) = 1; +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst meta.expr.let.typst storage.type.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst entity.name.function.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.comma.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.comma.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst keyword.operator.assignment.typst +# ^ source.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst punctuation.terminator.statement.typst +>#let f(a, (b, c: d)) = 1; +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst meta.expr.let.typst storage.type.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst entity.name.function.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.comma.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.comma.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.colon.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst keyword.operator.assignment.typst +# ^ source.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst punctuation.terminator.statement.typst +>#let f((a, b)) = 1; +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst meta.expr.let.typst storage.type.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst entity.name.function.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.comma.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst keyword.operator.assignment.typst +# ^ source.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst punctuation.terminator.statement.typst +>#let f((a, (c: (b: e)))) = 1; +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst meta.expr.let.typst storage.type.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst entity.name.function.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.comma.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.colon.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.colon.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst keyword.operator.assignment.typst +# ^ source.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst punctuation.terminator.statement.typst +>#let f((a, ..)) = 1; +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst meta.expr.let.typst storage.type.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst entity.name.function.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.comma.typst +# ^ source.typst meta.expr.let.typst +# ^^ source.typst meta.expr.let.typst keyword.operator.range.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst keyword.operator.assignment.typst +# ^ source.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst punctuation.terminator.statement.typst +>#let f((.., a)) = 1; +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst meta.expr.let.typst storage.type.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst entity.name.function.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^^ source.typst meta.expr.let.typst keyword.operator.range.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.comma.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst keyword.operator.assignment.typst +# ^ source.typst +# ^ source.typst constant.numeric.integer.typst +# ^ source.typst punctuation.terminator.statement.typst \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/basic/markup_constant.typ b/syntaxes/textmate/tests/unit/basic/markup_constant.typ new file mode 100644 index 00000000..e8f8d16a --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/markup_constant.typ @@ -0,0 +1,3 @@ +1 +# +#1pt #1pt \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/basic/markup_constant.typ.snap b/syntaxes/textmate/tests/unit/basic/markup_constant.typ.snap new file mode 100644 index 00000000..d493599d --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/markup_constant.typ.snap @@ -0,0 +1,10 @@ +>1 +#^^ source.typst +># +#^ source.typst punctuation.definition.hash.typst +>#1pt #1pt +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst constant.numeric.length.typst +# ^ source.typst +# ^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst constant.numeric.length.typst \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/basic/raw.typ b/syntaxes/textmate/tests/unit/basic/raw.typ new file mode 100644 index 00000000..9da4d9ff --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/raw.typ @@ -0,0 +1,24 @@ +```typ +abc +``` + +```typ abc ``` + +#```typ abc``` + +#(```typ abc```) + +#text(```typ https://zh.wikipedia.org```) + +````typ +https://zh.wikipedia.org +```` + +#( + ```typ + writing-markup + ```, + ```typ + writing-markup + ``` +) diff --git a/syntaxes/textmate/tests/unit/basic/raw.typ.snap b/syntaxes/textmate/tests/unit/basic/raw.typ.snap new file mode 100644 index 00000000..771c5198 --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/raw.typ.snap @@ -0,0 +1,74 @@ +>```typ +#^^^ source.typst markup.raw.block.typst punctuation.definition.raw.begin.typst +# ^^^ source.typst markup.raw.block.typst fenced_code.block.language.typst +>abc +#^^^^ source.typst markup.raw.block.typst meta.embedded.block.typst +>``` +#^^^ source.typst markup.raw.block.typst punctuation.definition.raw.end.typst +> +>```typ abc ``` +#^^^ source.typst markup.raw.block.typst punctuation.definition.raw.begin.typst +# ^^^ source.typst markup.raw.block.typst fenced_code.block.language.typst +# ^^^^^ source.typst markup.raw.block.typst meta.embedded.block.typst +# ^^^ source.typst markup.raw.block.typst punctuation.definition.raw.end.typst +> +>#```typ abc``` +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst markup.raw.block.typst punctuation.definition.raw.begin.typst +# ^^^ source.typst markup.raw.block.typst fenced_code.block.language.typst +# ^^^^ source.typst markup.raw.block.typst meta.embedded.block.typst +# ^^^ source.typst markup.raw.block.typst punctuation.definition.raw.end.typst +> +>#(```typ abc```) +#^ source.typst punctuation.definition.hash.typst +# ^ source.typst meta.brace.round.typst +# ^^^ source.typst markup.raw.block.typst punctuation.definition.raw.begin.typst +# ^^^ source.typst markup.raw.block.typst fenced_code.block.language.typst +# ^^^^ source.typst markup.raw.block.typst meta.embedded.block.typst +# ^^^ source.typst markup.raw.block.typst punctuation.definition.raw.end.typst +# ^ source.typst meta.brace.round.typst +> +>#text(```typ https://zh.wikipedia.org```) +#^ source.typst punctuation.definition.hash.typst +# ^^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^^^ source.typst markup.raw.block.typst punctuation.definition.raw.begin.typst +# ^^^ source.typst markup.raw.block.typst fenced_code.block.language.typst +# ^ source.typst markup.raw.block.typst meta.embedded.block.typst +# ^^^^^^^^^^^^^^^^^^^^^^^^ source.typst markup.raw.block.typst meta.embedded.block.typst markup.underline.link.typst +# ^^^ source.typst markup.raw.block.typst punctuation.definition.raw.end.typst +# ^ source.typst meta.brace.round.typst +> +>````typ +#^^^^ source.typst markup.raw.block.typst punctuation.definition.raw.begin.typst +# ^^^ source.typst markup.raw.block.typst fenced_code.block.language.typst +>https://zh.wikipedia.org +#^^^^^^^^^^^^^^^^^^^^^^^^ source.typst markup.raw.block.typst meta.embedded.block.typst markup.underline.link.typst +>```` +#^^^^ source.typst markup.raw.block.typst punctuation.definition.raw.end.typst +> +>#( +#^ source.typst punctuation.definition.hash.typst +# ^ source.typst meta.brace.round.typst +> ```typ +#^^ source.typst +# ^^^ source.typst markup.raw.block.typst punctuation.definition.raw.begin.typst +# ^^^ source.typst markup.raw.block.typst fenced_code.block.language.typst +> writing-markup +#^^^^^^^^^^^^^^^^^ source.typst markup.raw.block.typst meta.embedded.block.typst +> ```, +#^^ source.typst markup.raw.block.typst meta.embedded.block.typst +# ^^^ source.typst markup.raw.block.typst punctuation.definition.raw.end.typst +# ^ source.typst punctuation.separator.comma.typst +> ```typ +#^^ source.typst +# ^^^ source.typst markup.raw.block.typst punctuation.definition.raw.begin.typst +# ^^^ source.typst markup.raw.block.typst fenced_code.block.language.typst +> writing-markup +#^^^^^^^^^^^^^^^^^ source.typst markup.raw.block.typst meta.embedded.block.typst +> ``` +#^^ source.typst markup.raw.block.typst meta.embedded.block.typst +# ^^^ source.typst markup.raw.block.typst punctuation.definition.raw.end.typst +>) +#^ source.typst meta.brace.round.typst +> \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/basic/raw_nest.typ b/syntaxes/textmate/tests/unit/basic/raw_nest.typ new file mode 100644 index 00000000..baf9157f --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/raw_nest.typ @@ -0,0 +1,13 @@ +````typ +```typ +abc +``` +```` + +`````typ +````md +```typ +abc +``` +```` +````` diff --git a/syntaxes/textmate/tests/unit/basic/raw_nest.typ.snap b/syntaxes/textmate/tests/unit/basic/raw_nest.typ.snap new file mode 100644 index 00000000..5e788e93 --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/raw_nest.typ.snap @@ -0,0 +1,30 @@ +>````typ +#^^^^ source.typst markup.raw.block.typst punctuation.definition.raw.begin.typst +# ^^^ source.typst markup.raw.block.typst fenced_code.block.language.typst +>```typ +#^^^ source.typst markup.raw.block.typst meta.embedded.block.typst markup.raw.block.typst punctuation.definition.raw.begin.typst +# ^^^ source.typst markup.raw.block.typst meta.embedded.block.typst markup.raw.block.typst fenced_code.block.language.typst +>abc +#^^^^ source.typst markup.raw.block.typst meta.embedded.block.typst markup.raw.block.typst meta.embedded.block.typst +>``` +#^^^ source.typst markup.raw.block.typst meta.embedded.block.typst markup.raw.block.typst punctuation.definition.raw.end.typst +>```` +#^^^^ source.typst markup.raw.block.typst punctuation.definition.raw.end.typst +> +>`````typ +#^^^^^ source.typst markup.raw.block.typst punctuation.definition.raw.begin.typst +# ^^^ source.typst markup.raw.block.typst fenced_code.block.language.typst +>````md +#^^^^ source.typst markup.raw.block.typst meta.embedded.block.typst markup.raw.block.typst punctuation.definition.raw.begin.typst +# ^^^ source.typst markup.raw.block.typst meta.embedded.block.typst markup.raw.block.typst fenced_code.block.language +>```typ +#^^^^^^^ source.typst markup.raw.block.typst meta.embedded.block.typst markup.raw.block.typst +>abc +#^^^^ source.typst markup.raw.block.typst meta.embedded.block.typst markup.raw.block.typst +>``` +#^^^^ source.typst markup.raw.block.typst meta.embedded.block.typst markup.raw.block.typst +>```` +#^^^^ source.typst markup.raw.block.typst meta.embedded.block.typst markup.raw.block.typst punctuation.definition.raw.end.typst +>````` +#^^^^^ source.typst markup.raw.block.typst punctuation.definition.raw.end.typst +> \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/basic/set.typ b/syntaxes/textmate/tests/unit/basic/set.typ new file mode 100644 index 00000000..c4584c18 --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/set.typ @@ -0,0 +1,8 @@ +#set text(fill: red); +#set text(fill: red) +#set text("") +#set text(red) +#set list.item(red); +#set list.item(fill: red); +#set (text(fill: red)); +#set ((text(fill: red))); \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/basic/set.typ.snap b/syntaxes/textmate/tests/unit/basic/set.typ.snap new file mode 100644 index 00000000..93ee85eb --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/set.typ.snap @@ -0,0 +1,95 @@ +>#set text(fill: red); +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst keyword.control.typst +# ^ source.typst +# ^^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^^^^ source.typst variable.other.readwrite.typst +# ^ source.typst punctuation.separator.colon.typst +# ^ source.typst +# ^^^ source.typst variable.other.readwrite.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst punctuation.terminator.statement.typst +>#set text(fill: red) +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst keyword.control.typst +# ^ source.typst +# ^^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^^^^ source.typst variable.other.readwrite.typst +# ^ source.typst punctuation.separator.colon.typst +# ^ source.typst +# ^^^ source.typst variable.other.readwrite.typst +# ^ source.typst meta.brace.round.typst +>#set text("") +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst keyword.control.typst +# ^ source.typst +# ^^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^ source.typst meta.brace.round.typst +>#set text(red) +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst keyword.control.typst +# ^ source.typst +# ^^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^^^ source.typst variable.other.readwrite.typst +# ^ source.typst meta.brace.round.typst +>#set list.item(red); +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst keyword.control.typst +# ^ source.typst +# ^^^^ source.typst variable.other.readwrite.typst +# ^ source.typst keyword.operator.accessor.typst +# ^^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^^^ source.typst variable.other.readwrite.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst punctuation.terminator.statement.typst +>#set list.item(fill: red); +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst keyword.control.typst +# ^ source.typst +# ^^^^ source.typst variable.other.readwrite.typst +# ^ source.typst keyword.operator.accessor.typst +# ^^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^^^^ source.typst variable.other.readwrite.typst +# ^ source.typst punctuation.separator.colon.typst +# ^ source.typst +# ^^^ source.typst variable.other.readwrite.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst punctuation.terminator.statement.typst +>#set (text(fill: red)); +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst keyword.control.typst +# ^ source.typst +# ^ source.typst meta.brace.round.typst +# ^^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^^^^ source.typst variable.other.readwrite.typst +# ^ source.typst punctuation.separator.colon.typst +# ^ source.typst +# ^^^ source.typst variable.other.readwrite.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst punctuation.terminator.statement.typst +>#set ((text(fill: red))); +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst keyword.control.typst +# ^ source.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst meta.brace.round.typst +# ^^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^^^^ source.typst variable.other.readwrite.typst +# ^ source.typst punctuation.separator.colon.typst +# ^ source.typst +# ^^^ source.typst variable.other.readwrite.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst punctuation.terminator.statement.typst \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/basic/show.typ b/syntaxes/textmate/tests/unit/basic/show.typ new file mode 100644 index 00000000..562c79ed --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/show.typ @@ -0,0 +1,5 @@ +#show: it => it +#show text: it => it +#show: rect +#show: list.item.with() +#show: rect.with(width: 1pt) diff --git a/syntaxes/textmate/tests/unit/basic/show.typ.snap b/syntaxes/textmate/tests/unit/basic/show.typ.snap new file mode 100644 index 00000000..97d82b4c --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/show.typ.snap @@ -0,0 +1,55 @@ +>#show: it => it +#^ source.typst punctuation.definition.hash.typst +# ^^^^ source.typst keyword.control.typst +# ^ source.typst punctuation.separator.colon.typst +# ^ source.typst +# ^^ source.typst variable.other.readwrite.typst +# ^ source.typst +# ^^ source.typst keyword.operator.arrow.typst +# ^ source.typst +# ^^ source.typst variable.other.readwrite.typst +>#show text: it => it +#^ source.typst punctuation.definition.hash.typst +# ^^^^ source.typst keyword.control.typst +# ^ source.typst +# ^^^^ source.typst variable.other.readwrite.typst +# ^ source.typst punctuation.separator.colon.typst +# ^ source.typst +# ^^ source.typst variable.other.readwrite.typst +# ^ source.typst +# ^^ source.typst keyword.operator.arrow.typst +# ^ source.typst +# ^^ source.typst variable.other.readwrite.typst +>#show: rect +#^ source.typst punctuation.definition.hash.typst +# ^^^^ source.typst keyword.control.typst +# ^ source.typst punctuation.separator.colon.typst +# ^ source.typst +# ^^^^ source.typst variable.other.readwrite.typst +>#show: list.item.with() +#^ source.typst punctuation.definition.hash.typst +# ^^^^ source.typst keyword.control.typst +# ^ source.typst punctuation.separator.colon.typst +# ^ source.typst +# ^^^^ source.typst variable.other.readwrite.typst +# ^ source.typst keyword.operator.accessor.typst +# ^^^^ source.typst variable.other.readwrite.typst +# ^ source.typst keyword.operator.accessor.typst +# ^^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst meta.brace.round.typst +>#show: rect.with(width: 1pt) +#^ source.typst punctuation.definition.hash.typst +# ^^^^ source.typst keyword.control.typst +# ^ source.typst punctuation.separator.colon.typst +# ^ source.typst +# ^^^^ source.typst variable.other.readwrite.typst +# ^ source.typst keyword.operator.accessor.typst +# ^^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^^^^^ source.typst variable.other.readwrite.typst +# ^ source.typst punctuation.separator.colon.typst +# ^ source.typst +# ^^^ source.typst constant.numeric.length.typst +# ^ source.typst meta.brace.round.typst +> \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/basic/string.typ b/syntaxes/textmate/tests/unit/basic/string.typ new file mode 100644 index 00000000..db455150 --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/string.typ @@ -0,0 +1,10 @@ +#"abc" + 1 +#"@myriaddreamin" + 1 +#"[a]" + 1 +#"{a}" + 1 +#"\\a" + 1 +#"\\" + 1 +#"\\\a" + 1 +#"\v" + 1 +#"\我" + 1 +#"//" \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/basic/string.typ.snap b/syntaxes/textmate/tests/unit/basic/string.typ.snap new file mode 100644 index 00000000..bae1c27d --- /dev/null +++ b/syntaxes/textmate/tests/unit/basic/string.typ.snap @@ -0,0 +1,61 @@ +>#"abc" + 1 +#^ source.typst punctuation.definition.hash.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^^^ source.typst string.quoted.double.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^^^^^ source.typst +>#"@myriaddreamin" + 1 +#^ source.typst punctuation.definition.hash.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^^^^^^^^^^^^^^ source.typst string.quoted.double.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^^^^^ source.typst +>#"[a]" + 1 +#^ source.typst punctuation.definition.hash.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^^^ source.typst string.quoted.double.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^^^^^ source.typst +>#"{a}" + 1 +#^ source.typst punctuation.definition.hash.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^^^ source.typst string.quoted.double.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^^^^^ source.typst +>#"\\a" + 1 +#^ source.typst punctuation.definition.hash.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^^ source.typst string.quoted.double.typst constant.character.escape.string.typst +# ^ source.typst string.quoted.double.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^^^^^ source.typst +>#"\\" + 1 +#^ source.typst punctuation.definition.hash.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^^ source.typst string.quoted.double.typst constant.character.escape.string.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^^^^^ source.typst +>#"\\\a" + 1 +#^ source.typst punctuation.definition.hash.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^^ source.typst string.quoted.double.typst constant.character.escape.string.typst +# ^^ source.typst string.quoted.double.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^^^^^ source.typst +>#"\v" + 1 +#^ source.typst punctuation.definition.hash.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^^ source.typst string.quoted.double.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^^^^^ source.typst +>#"\我" + 1 +#^ source.typst punctuation.definition.hash.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^^ source.typst string.quoted.double.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^^^^^ source.typst +>#"//" +#^ source.typst punctuation.definition.hash.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^^ source.typst string.quoted.double.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/bugs/comment-in-string.typ b/syntaxes/textmate/tests/unit/bugs/comment-in-string.typ new file mode 100644 index 00000000..e5cab4d3 --- /dev/null +++ b/syntaxes/textmate/tests/unit/bugs/comment-in-string.typ @@ -0,0 +1 @@ +#link("https://myriad-dreamin.github.io/typst.ts/cookery/guide/compiler/ts-cli.html")[Form1]: Render to SVG and then embed it as a high-quality vectored image directly. \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/bugs/comment-in-string.typ.snap b/syntaxes/textmate/tests/unit/bugs/comment-in-string.typ.snap new file mode 100644 index 00000000..e1c4a4e1 --- /dev/null +++ b/syntaxes/textmate/tests/unit/bugs/comment-in-string.typ.snap @@ -0,0 +1,13 @@ +>#link("https://myriad-dreamin.github.io/typst.ts/cookery/guide/compiler/ts-cli.html")[Form1]: Render to SVG and then embed it as a high-quality vectored image directly. +#^ source.typst punctuation.definition.hash.typst +# ^^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.typst string.quoted.double.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst meta.brace.square.typ +# ^^^^^ source.typst +# ^ source.typst meta.brace.square.typst +# ^ source.typst +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.typst \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/bugs/hover.typ b/syntaxes/textmate/tests/unit/bugs/hover.typ new file mode 100644 index 00000000..109e844a --- /dev/null +++ b/syntaxes/textmate/tests/unit/bugs/hover.typ @@ -0,0 +1 @@ +#let code(it, args: any, res: none, scope: (:)); \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/bugs/hover.typ.snap b/syntaxes/textmate/tests/unit/bugs/hover.typ.snap new file mode 100644 index 00000000..fb57e0f0 --- /dev/null +++ b/syntaxes/textmate/tests/unit/bugs/hover.typ.snap @@ -0,0 +1,29 @@ +>#let code(it, args: any, res: none, scope: (:)); +#^ source.typst punctuation.definition.hash.typst +# ^^^ source.typst meta.expr.let.typst storage.type.typst +# ^ source.typst meta.expr.let.typst +# ^^^^ source.typst meta.expr.let.typst entity.name.function.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.comma.typst +# ^ source.typst meta.expr.let.typst +# ^^^^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.colon.typst +# ^ source.typst meta.expr.let.typst +# ^^^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.comma.typst +# ^ source.typst meta.expr.let.typst +# ^^^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.colon.typst +# ^ source.typst meta.expr.let.typst +# ^^^^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.comma.typst +# ^ source.typst meta.expr.let.typst +# ^^^^^ source.typst meta.expr.let.typst variable.other.readwrite.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.colon.typst +# ^ source.typst meta.expr.let.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst punctuation.separator.colon.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst meta.expr.let.typst meta.brace.round.typst +# ^ source.typst punctuation.terminator.statement.typst \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/bugs/ref-in-string.typ b/syntaxes/textmate/tests/unit/bugs/ref-in-string.typ new file mode 100644 index 00000000..55da5f1f --- /dev/null +++ b/syntaxes/textmate/tests/unit/bugs/ref-in-string.typ @@ -0,0 +1 @@ +#"@myriaddreamin" \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/bugs/ref-in-string.typ.snap b/syntaxes/textmate/tests/unit/bugs/ref-in-string.typ.snap new file mode 100644 index 00000000..ec3df7f7 --- /dev/null +++ b/syntaxes/textmate/tests/unit/bugs/ref-in-string.typ.snap @@ -0,0 +1,5 @@ +>#"@myriaddreamin" +#^ source.typst punctuation.definition.hash.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^^^^^^^^^^^^^^ source.typst string.quoted.double.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/bugs/ts-intro.typ b/syntaxes/textmate/tests/unit/bugs/ts-intro.typ new file mode 100644 index 00000000..978047fc --- /dev/null +++ b/syntaxes/textmate/tests/unit/bugs/ts-intro.typ @@ -0,0 +1 @@ + by #text(fill: rgb("#3c9123"), "server") and #text(fill: blue, "browser"), there would be a data flow like this: \ No newline at end of file diff --git a/syntaxes/textmate/tests/unit/bugs/ts-intro.typ.snap b/syntaxes/textmate/tests/unit/bugs/ts-intro.typ.snap new file mode 100644 index 00000000..e5e6ee2f --- /dev/null +++ b/syntaxes/textmate/tests/unit/bugs/ts-intro.typ.snap @@ -0,0 +1,36 @@ +> by #text(fill: rgb("#3c9123"), "server") and #text(fill: blue, "browser"), there would be a data flow like this: +#^^^^ source.typst +# ^ source.typst punctuation.definition.hash.typst +# ^^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^^^^ source.typst variable.other.readwrite.typst +# ^ source.typst punctuation.separator.colon.typst +# ^ source.typst +# ^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^^^^^^^ source.typst string.quoted.double.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst punctuation.separator.comma.typst +# ^ source.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^^^^^^ source.typst string.quoted.double.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^ source.typst meta.brace.round.typst +# ^^^^^ source.typst +# ^ source.typst punctuation.definition.hash.typst +# ^^^^ source.typst entity.name.function.typst +# ^ source.typst meta.brace.round.typst +# ^^^^ source.typst variable.other.readwrite.typst +# ^ source.typst punctuation.separator.colon.typst +# ^ source.typst +# ^^^^ source.typst variable.other.readwrite.typst +# ^ source.typst punctuation.separator.comma.typst +# ^ source.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^^^^^^^ source.typst string.quoted.double.typst +# ^ source.typst string.quoted.double.typst punctuation.definition.string.typst +# ^ source.typst meta.brace.round.typst +# ^ source.typst +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.typst \ No newline at end of file diff --git a/syntaxes/textmate/typst.tmLanguage.yaml b/syntaxes/textmate/typst.tmLanguage.yaml new file mode 100644 index 00000000..6e19ca69 --- /dev/null +++ b/syntaxes/textmate/typst.tmLanguage.yaml @@ -0,0 +1,1418 @@ +$schema: 'https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json' +scopeName: source.typst +name: typst +patterns: + - include: '#markup' +repository: + comments: + patterns: + - name: comment.block.typst + begin: /\* + end: \*/ + captures: + '0': + name: punctuation.definition.comment.typst + patterns: + - include: '#comments' + - name: comment.line.double-slash.typst + begin: '(?' + captures: + '1': + name: punctuation.definition.label.typst + - name: entity.other.reference.typst + match: '(@)[[:alpha:]_][[:alnum:]_-]*' + captures: + '1': + name: punctuation.definition.reference.typst + markup-hash: + patterns: + # hash and follows a space + - match: '(#)\s' + captures: + '1': + name: punctuation.definition.hash.typst + # hash and follows a empty + - match: '(#)(;)' + # hash and follows a code expression + captures: + '1': + name: punctuation.definition.hash.typst + '2': + name: punctuation.terminator.statement.typst + - begin: '#' + # name: 'markup.expr.typst' + end: '(?=\s)|(;)' + beginCaptures: + '0': + name: punctuation.definition.hash.typst + endCaptures: + '1': + name: punctuation.terminator.statement.typst + patterns: + - include: '#code-expr' + code-expr: + patterns: + # empty array () + - name: meta.array.empty.typst + match: \(\s*\) + # empty dictionary (:) + - name: meta.dictionary.empty.typst + match: \(\s*:\s*\) + # parentheisized expressions: (...) + - begin: \( + end: \) + beginCaptures: + '0': + name: meta.brace.round.typst + endCaptures: + '0': + name: meta.brace.round.typst + patterns: + - include: '#literal-content' + # bracketed expressions: [...] + - begin: \[ + end: \] + beginCaptures: + '0': + name: meta.brace.square.typ + endCaptures: + '0': + name: meta.brace.square.typst + patterns: + - include: '#markup' + - name: entity.other.label.typst + match: '<[\p{XID_Start}_][\p{XID_Continue}_-]*>' + captures: + '1': + name: string.other.label.typst + - include: '#fenced_code_block' + - include: '#code-block' + # let expressions: let ident|pattern = expr + - name: meta.expr.let.typst + begin: '(let)\b' + end: '(?=\n)|(?=\=)|(?=\))|(?=;)|(?=])' + beginCaptures: + '1': + name: storage.type.typst + patterns: + - include: '#let-expr' + - begin: '(for)\b' + # debugging + # name: 'for.block.typst' + end: '(?=\n)|(?=\))|(?=;)|(?=])' + beginCaptures: + '1': + name: keyword.control.loop.typst + patterns: + - include: '#for-clause' + - begin: '(else)?\b(if)\b' + # debugging + # name: 'if.block.typst' + end: '(?=\n)|(?=\))|(?=;)|(?=])' + captures: + '1': + name: keyword.control.conditional.typst + '2': + name: keyword.control.conditional.typst + patterns: + - include: '#code-expr' + - match: '(while|as|in)\b' + captures: + '1': + name: keyword.control.typst + - begin: '(show)\b' + end: '(?=\n)|(?=\))|(?=;)|(?=])' + beginCaptures: + '1': + name: keyword.control.typst + patterns: + - include: '#show-expr' + - begin: '(set)\b' + end: '(?=\n)|(?=\))|(?=;)|(?=])' + beginCaptures: + '1': + name: keyword.control.typst + patterns: + - include: '#code-expr' + - begin: '(\b[\p{XID_Start}_][\p{XID_Continue}_-]*)(\()' + end: \) + beginCaptures: + '1': + name: entity.name.function.typst + '2': + name: meta.brace.round.typst + endCaptures: + '0': + name: meta.brace.round.typst + patterns: + - include: '#code-args' + - match: '(\b[\p{XID_Start}_][\p{XID_Continue}_-]*)\b' + captures: + '1': + name: variable.other.readwrite.typst + - include: '#constants' + - name: keyword.operator.arrow.typst + match: => + - name: keyword.operator.accessor.typst + match: \. + - name: keyword.control.loop.typst + match: \b(while|break|continue)\b + - name: keyword.operator.range.typst + match: \.\. + - name: keyword.operator.arithmetic.typst + match: '\+|\|/|(?=|> + - begin: '(\+=|-=|\*=|/=|=)' + end: '(?=\n)|(?=\))|(?=;)|(?=])|(?=\})' + beginCaptures: + '1': + name: keyword.operator.assignment.typst + patterns: + - include: '#code-expr' + - name: keyword.operator.word.typst + match: \b(and|or|not)\b + - name: keyword.control.import.typst + match: \b(import|include|export)\b + - name: keyword.control.flow.typst + match: \b(return)\b + code-block: + patterns: + # brace expressions: {...} + - begin: \{ + end: (\}) + beginCaptures: + '0': + name: meta.brace.curly.typst + endCaptures: + '1': + name: meta.brace.curly.typst + patterns: + - include: '#code' + let-expr: + patterns: + - begin: '(\b[\p{XID_Start}_][\p{XID_Continue}_-]*)(\()' + end: \) + beginCaptures: + '1': + name: entity.name.function.typst + '2': + name: meta.brace.round.typst + endCaptures: + '0': + name: meta.brace.round.typst + patterns: + - name: meta.parameters.typst + include: '#code-params' + - include: '#pattern-binding-items' + - include: '#identifier' + # - include: '#code-expr' + for-clause: + patterns: + - begin: '([\s\S]+)(as|in)\b' + end: '(?=[{\);\]])' + beginCaptures: + '1': + patterns: + - include: '#pattern-binding-items' + - include: '#identifier' + '2': + name: keyword.other.typst + patterns: + - include: '#code-expr' + - include: '#code-block' + show-expr: + patterns: + - include: '#code-expr' + - name: punctuation.separator.colon.typst + match: ':' + pattern-binding-assign: + patterns: + - begin: '\(' + end: '(\))\s*(=)\s*' + beginCaptures: + '0': + name: meta.brace.round.typst + endCaptures: + '1': + name: meta.brace.round.typst + '2': + name: keyword.operator.assignment.typst + patterns: + - include: '#pattern-binding-items' + - include: '#code-expr' + pattern-binding-items: + patterns: + # rest binding + - match: '(\.\.)(\b[\p{XID_Start}_][\p{XID_Continue}_-]*)?' + # debugging + # name: block.pattern-binding.typst + captures: + '1': + name: keyword.operator.range.typst + '2': + name: variable.other.readwrite.typst + # recursive binding + - begin: '\(' + end: '\)' + beginCaptures: + '0': + name: meta.brace.round.typst + endCaptures: + '0': + name: meta.brace.round.typst + patterns: + - include: '#pattern-binding-items' + # parameter binding + - include: '#identifier' + - name: punctuation.separator.colon.typst + match: ':' + - name: punctuation.separator.comma.typst + match: ',' + literal-content: + patterns: + - include: '#code-expr' + - name: punctuation.separator.colon.typst + match: ':' + - name: punctuation.separator.comma.typst + match: ',' + code-args: + patterns: + - include: '#code-expr' + - name: punctuation.separator.colon.typst + match: ':' + - name: punctuation.separator.comma.typst + match: ',' + code-params: + patterns: + - name: meta.parameter.binding.typst + include: '#pattern-binding-items' + - name: punctuation.separator.colon.typst + match: ':' + - name: punctuation.separator.comma.typst + match: ',' + identifier: + patterns: + - match: '(\b[\p{XID_Start}_][\p{XID_Continue}_-]*)\b' + captures: + '1': + name: variable.other.readwrite.typst + code: + patterns: + - include: '#common' + - name: comment.line.double-slash.typst + begin: // + end: |+ + + beginCaptures: + '0': + name: punctuation.definition.comment.typst + - name: punctuation.separator.colon.typst + match: ';' + - include: '#code-expr' + constants: + patterns: + - name: constant.language.none.typst + match: \bnone\b + - name: constant.language.auto.typst + match: \bauto\b + - name: constant.language.boolean.typst + match: \b(true|false)\b + - name: constant.numeric.length.typst + match: '\b(\d*)?\.?\d+([eE][+-]?\d+)?(mm|pt|cm|in|em)\b' + - name: constant.numeric.angle.typst + match: '\b(\d*)?\.?\d+([eE][+-]?\d+)?(rad|deg)\b' + - name: constant.numeric.percentage.typst + match: '\b(\d*)?\.?\d+([eE][+-]?\d+)?%' + - name: constant.numeric.fr.typst + match: '\b(\d*)?\.?\d+([eE][+-]?\d+)?fr' + - name: constant.numeric.integer.typst + match: \b\d+\b + - name: constant.numeric.float.typst + match: '\b(\d*)?\.?\d+([eE][+-]?\d+)?\b' + - name: string.quoted.double.typst + begin: '"' + end: '"' + captures: + '0': + name: punctuation.definition.string.typst + patterns: + - name: constant.character.escape.string.typst + match: '\\([\\"nrt]|u\{?[0-9a-zA-Z]*\}?)' + - name: string.other.math.typst + begin: \$ + end: \$ + captures: + '0': + name: punctuation.definition.string.math.typst + fenced_code_block_typst: + begin: '(`{3,})\s*(?i:(typ|typst)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.typst + patterns: + - include: source.typst + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_css: + begin: '(`{3,})\s*(?i:(css|css.erb)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.css + patterns: + - include: source.css + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_basic: + begin: '(`{3,})\s*(?i:(html|htm|shtml|xhtml|inc|tmpl|tpl)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.html + patterns: + - include: text.html.basic + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_ini: + begin: '(`{3,})\s*(?i:(ini|conf)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.ini + patterns: + - include: source.ini + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_java: + begin: '(`{3,})\s*(?i:(java|bsh)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.java + patterns: + - include: source.java + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_lua: + begin: '(`{3,})\s*(?i:(lua)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.lua + patterns: + - include: source.lua + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_makefile: + begin: '(`{3,})\s*(?i:(Makefile|makefile|GNUmakefile|OCamlMakefile)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.makefile + patterns: + - include: source.makefile + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_perl: + begin: '(`{3,})\s*(?i:(perl|pl|pm|pod|t|PL|psgi|vcl)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.perl + patterns: + - include: source.perl + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_r: + begin: '(`{3,})\s*(?i:(R|r|s|S|Rprofile|\{\.r.+?\})\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.r + patterns: + - include: source.r + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_ruby: + begin: '(`{3,})\s*(?i:(ruby|rb|rbx|rjs|Rakefile|rake|cgi|fcgi|gemspec|irbrc|Capfile|ru|prawn|Cheffile|Gemfile|Guardfile|Hobofile|Vagrantfile|Appraisals|Rantfile|Berksfile|Berksfile.lock|Thorfile|Puppetfile)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.ruby + patterns: + - include: source.ruby + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_php: + begin: '(`{3,})\s*(?i:(php|php3|php4|php5|phpt|phtml|aw|ctp)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.php + patterns: + - include: text.html.basic + - include: source.php + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_sql: + begin: '(`{3,})\s*(?i:(sql|ddl|dml)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.sql + patterns: + - include: source.sql + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_vs_net: + begin: '(`{3,})\s*(?i:(vb)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.vs_net + patterns: + - include: source.asp.vb.net + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_xml: + begin: '(`{3,})\s*(?i:(xml|xsd|tld|jsp|pt|cpt|dtml|rss|opml)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.xml + patterns: + - include: text.xml + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_xsl: + begin: '(`{3,})\s*(?i:(xsl|xslt)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.xsl + patterns: + - include: text.xml.xsl + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_yaml: + begin: '(`{3,})\s*(?i:(yaml|yml)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.yaml + patterns: + - include: source.yaml + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_dosbatch: + begin: '(`{3,})\s*(?i:(bat|batch)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.dosbatch + patterns: + - include: source.batchfile + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_clojure: + begin: '(`{3,})\s*(?i:(clj|cljs|clojure)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.clojure + patterns: + - include: source.clojure + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_coffee: + begin: '(`{3,})\s*(?i:(coffee|Cakefile|coffee.erb)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.coffee + patterns: + - include: source.coffee + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_c: + begin: '(`{3,})\s*(?i:(c|h)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.c + patterns: + - include: source.c + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_cpp: + begin: '(`{3,})\s*(?i:(cpp|c\+\+|cxx)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.cpp source.cpp + patterns: + - include: source.cpp + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_diff: + begin: '(`{3,})\s*(?i:(patch|diff|rej)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.diff + patterns: + - include: source.diff + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_dockerfile: + begin: '(`{3,})\s*(?i:(dockerfile|Dockerfile)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.dockerfile + patterns: + - include: source.dockerfile + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_git_commit: + begin: '(`{3,})\s*(?i:(COMMIT_EDITMSG|MERGE_MSG)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.git_commit + patterns: + - include: text.git-commit + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_git_rebase: + begin: '(`{3,})\s*(?i:(git-rebase-todo)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.git_rebase + patterns: + - include: text.git-rebase + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_go: + begin: '(`{3,})\s*(?i:(go|golang)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.go + patterns: + - include: source.go + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_groovy: + begin: '(`{3,})\s*(?i:(groovy|gvy)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.groovy + patterns: + - include: source.groovy + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_pug: + begin: '(`{3,})\s*(?i:(jade|pug)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.pug + patterns: + - include: text.pug + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_js: + begin: '(`{3,})\s*(?i:(js|jsx|javascript|es6|mjs|cjs|dataviewjs|\{\.js.+?\})\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.javascript + patterns: + - include: source.js + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_js_regexp: + begin: '(`{3,})\s*(?i:(regexp)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.js_regexp + patterns: + - include: source.js.regexp + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_json: + begin: '(`{3,})\s*(?i:(json|json5|sublime-settings|sublime-menu|sublime-keymap|sublime-mousemap|sublime-theme|sublime-build|sublime-project|sublime-completions)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.json + patterns: + - include: source.json + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_jsonc: + begin: '(`{3,})\s*(?i:(jsonc)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.jsonc + patterns: + - include: source.json.comments + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_less: + begin: '(`{3,})\s*(?i:(less)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.less + patterns: + - include: source.css.less + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_objc: + begin: '(`{3,})\s*(?i:(objectivec|objective-c|mm|objc|obj-c|m|h)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.objc + patterns: + - include: source.objc + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_swift: + begin: '(`{3,})\s*(?i:(swift)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.swift + patterns: + - include: source.swift + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_scss: + begin: '(`{3,})\s*(?i:(scss)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.scss + patterns: + - include: source.css.scss + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_perl6: + begin: '(`{3,})\s*(?i:(perl6|p6|pl6|pm6|nqp)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.perl6 + patterns: + - include: source.perl.6 + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_powershell: + begin: '(`{3,})\s*(?i:(powershell|ps1|psm1|psd1)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.powershell + patterns: + - include: source.powershell + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_python: + begin: '(`{3,})\s*(?i:(python|py|py3|rpy|pyw|cpy|SConstruct|Sconstruct|sconstruct|SConscript|gyp|gypi|\{\.python.+?\})\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.python + patterns: + - include: source.python + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_julia: + begin: '(`{3,})\s*(?i:(julia|\{\.julia.+?\})\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.julia + patterns: + - include: source.julia + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_regexp_python: + begin: '(`{3,})\s*(?i:(re)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.regexp_python + patterns: + - include: source.regexp.python + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_rust: + begin: '(`{3,})\s*(?i:(rust|rs|\{\.rust.+?\})\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.rust + patterns: + - include: source.rust + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_scala: + begin: '(`{3,})\s*(?i:(scala|sbt)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.scala + patterns: + - include: source.scala + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_shell: + begin: '(`{3,})\s*(?i:(shell|sh|bash|zsh|bashrc|bash_profile|bash_login|profile|bash_logout|.textmate_init|\{\.bash.+?\})\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.shellscript + patterns: + - include: source.shell + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_ts: + begin: '(`{3,})\s*(?i:(typescript|ts)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.typescript + patterns: + - include: source.ts + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_tsx: + begin: '(`{3,})\s*(?i:(tsx)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.typescriptreact + patterns: + - include: source.tsx + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_csharp: + begin: '(`{3,})\s*(?i:(cs|csharp|c#)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.csharp + patterns: + - include: source.cs + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_fsharp: + begin: '(`{3,})\s*(?i:(fs|fsharp|f#)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.fsharp + patterns: + - include: source.fsharp + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_dart: + begin: '(`{3,})\s*(?i:(dart)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.dart + patterns: + - include: source.dart + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_handlebars: + begin: '(`{3,})\s*(?i:(handlebars|hbs)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.handlebars + patterns: + - include: text.html.handlebars + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_markdown: + begin: '(`{3,})\s*(?i:(markdown|md)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.markdown + patterns: + - include: text.html.markdown + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_log: + begin: '(`{3,})\s*(?i:(log)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.log + patterns: + - include: text.log + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_erlang: + begin: '(`{3,})\s*(?i:(erlang)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.erlang + patterns: + - include: source.erlang + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_elixir: + begin: '(`{3,})\s*(?i:(elixir)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.elixir + patterns: + - include: source.elixir + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_latex: + begin: '(`{3,})\s*(?i:(latex|tex)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.latex + patterns: + - include: text.tex.latex + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_bibtex: + begin: '(`{3,})\s*(?i:(bibtex)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.bibtex + patterns: + - include: text.bibtex + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block_twig: + begin: '(`{3,})\s*(?i:(twig)\b)' + # ([\s\S]*)(\1) + end: (\1) + name: markup.raw.block.typst + contentName: meta.embedded.block.twig + patterns: + - include: source.twig + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language.typst + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + fenced_code_block: + patterns: + - include: '#fenced_code_block_typst' + - include: '#fenced_code_block_css' + - include: '#fenced_code_block_basic' + - include: '#fenced_code_block_ini' + - include: '#fenced_code_block_java' + - include: '#fenced_code_block_lua' + - include: '#fenced_code_block_makefile' + - include: '#fenced_code_block_perl' + - include: '#fenced_code_block_r' + - include: '#fenced_code_block_ruby' + - include: '#fenced_code_block_php' + - include: '#fenced_code_block_sql' + - include: '#fenced_code_block_vs_net' + - include: '#fenced_code_block_xml' + - include: '#fenced_code_block_xsl' + - include: '#fenced_code_block_yaml' + - include: '#fenced_code_block_dosbatch' + - include: '#fenced_code_block_clojure' + - include: '#fenced_code_block_coffee' + - include: '#fenced_code_block_c' + - include: '#fenced_code_block_cpp' + - include: '#fenced_code_block_diff' + - include: '#fenced_code_block_dockerfile' + - include: '#fenced_code_block_git_commit' + - include: '#fenced_code_block_git_rebase' + - include: '#fenced_code_block_go' + - include: '#fenced_code_block_groovy' + - include: '#fenced_code_block_pug' + - include: '#fenced_code_block_js' + - include: '#fenced_code_block_js_regexp' + - include: '#fenced_code_block_json' + - include: '#fenced_code_block_jsonc' + - include: '#fenced_code_block_less' + - include: '#fenced_code_block_objc' + - include: '#fenced_code_block_swift' + - include: '#fenced_code_block_scss' + - include: '#fenced_code_block_perl6' + - include: '#fenced_code_block_powershell' + - include: '#fenced_code_block_python' + - include: '#fenced_code_block_julia' + - include: '#fenced_code_block_regexp_python' + - include: '#fenced_code_block_rust' + - include: '#fenced_code_block_scala' + - include: '#fenced_code_block_shell' + - include: '#fenced_code_block_ts' + - include: '#fenced_code_block_tsx' + - include: '#fenced_code_block_csharp' + - include: '#fenced_code_block_fsharp' + - include: '#fenced_code_block_dart' + - include: '#fenced_code_block_handlebars' + - include: '#fenced_code_block_markdown' + - include: '#fenced_code_block_log' + - include: '#fenced_code_block_erlang' + - include: '#fenced_code_block_elixir' + - include: '#fenced_code_block_latex' + - include: '#fenced_code_block_bibtex' + - include: '#fenced_code_block_twig' + - include: '#fenced_code_block_unknown' + fenced_code_block_unknown: + begin: '(`{3,})\s*(?=([^`]*)?$)' + beginCaptures: + '1': + name: punctuation.definition.raw.begin.typst + '2': + name: fenced_code.block.language + end: '(\1)' + endCaptures: + '1': + name: punctuation.definition.raw.end.typst + name: markup.raw.block.typst