Skip to content

Commit

Permalink
Quick fix release (#331)
Browse files Browse the repository at this point in the history
* Display invalid.illegal in red in development env

* Split screen language into its own file

* Link some fallback patterns into ATL and screen blocks

We'll need to take some time to set this up properly to prevent highlighting syntax in blocks that don't support them.
For now this will do though

* Disable multi-line string tags

* Added hbox support

* Fix call screen
  • Loading branch information
duckdoom4 authored Jun 4, 2023
1 parent f71c4ab commit 24c7cb5
Show file tree
Hide file tree
Showing 6 changed files with 577 additions and 281 deletions.
6 changes: 6 additions & 0 deletions examples/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
},
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "debug.invalid.illegal.unmatched.renpy",
"settings": {
"foreground": "#f00"
}
},
{
"scope": "renpy.meta.plain",
"settings": {
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,16 @@
"path": "./syntaxes/renpy.tmLanguage.json"
},
{
"scopeName": "source.renpy.python",
"path": "./syntaxes/renpy.python.tmLanguage.json"
"scopeName": "source.renpy.screen",
"path": "./syntaxes/renpy.screen.tmLanguage.json"
},
{
"scopeName": "source.renpy.atl",
"path": "./syntaxes/renpy.atl.tmLanguage.json"
},
{
"scopeName": "source.renpy.python",
"path": "./syntaxes/renpy.python.tmLanguage.json"
}
],
"snippets": [
Expand Down
109 changes: 82 additions & 27 deletions syntaxes/renpy.atl.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@
"repository": {
"atl": {
"comment": "https://www.renpy.org/doc/html/atl.html#atl-syntax-and-semantics",
"patterns": [{ "include": "#atl-keywords" }, { "include": "#atl-blocks" }, { "include": "#atl-simple-expression" }, { "include": "#atl-warper" }, { "include": "#atl-event" }, { "include": "#atl-on" }, { "include": "#atl-function" }]
"patterns": [
{ "include": "source.renpy#conditionals" },
{ "include": "#atl-keywords" },
{ "include": "#atl-warper" },
{ "include": "#atl-blocks" },
{ "include": "#atl-simple-expression" },
{ "include": "#atl-event" },
{ "include": "#atl-on" },
{ "include": "#atl-function" },
{ "include": "#atl-fallback" }
]
},
"atl-build-in-properties": {
"comment": "https://www.renpy.org/doc/html/atl.html#list-of-transform-properties",
Expand All @@ -24,67 +34,67 @@
},
{
"comment": "position props (int, absolute, or a float)",
"name": "support.type.property-name.transform.renpy",
"name": "support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy",
"match": "\\b(?<!\\.)(?:xpos|ypos|xanchor|yanchor|xcenter|ycenter|radius)\\b"
},
{
"comment": "position pair props",
"name": "support.type.property-name.transform.renpy",
"name": "support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy",
"match": "\\b(?<!\\.)(?:pos|anchor|xycenter|around|alignaround|matrixanchor)\\b"
},
{
"comment": "float props",
"name": "support.type.property-name.transform.renpy",
"name": "support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy",
"match": "\\b(?<!\\.)(?:xalign|yalign|zoom|xzoom|yzoom|alpha|additive|angle|delay|events|zpos)\\b"
},
{
"comment": "float pair props",
"name": "support.type.property-name.transform.renpy",
"name": "support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy",
"match": "\\b(?<!\\.)(?:align|knot)\\b"
},
{
"comment": "int props",
"name": "support.type.property-name.transform.renpy",
"name": "support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy",
"match": "\\b(?<!\\.)(?:xoffset|yoffset|xtile|ytile)\\b"
},
{
"comment": "int pair props",
"name": "support.type.property-name.transform.renpy",
"name": "support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy",
"match": "\\b(?<!\\.)(?:offset)\\b"
},
{
"comment": "boolean props",
"name": "support.type.property-name.transform.renpy",
"name": "support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy",
"match": "\\b(?<!\\.)(?:rotate_pad|transform_anchor|nearest|crop_relative|subpixel|zzoom)\\b"
},
{
"comment": "('#float' | None)",
"name": "support.type.property-name.transform.renpy",
"name": "support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy",
"match": "\\b(?<!\\.)(?:rotate|xpan|ypan|blur)\\b"
},
{
"comment": "('#position' | None)",
"name": "support.type.property-name.transform.renpy",
"name": "support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy",
"match": "\\b(?<!\\.)(?:xsize|ysize)\\b"
},
{
"comment": "('\\(int, int, int, int\\)' | '\\(float, float, float, float\\)' | None)",
"name": "support.type.property-name.transform.renpy",
"name": "support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy",
"match": "\\b(?<!\\.)(?:crop)\\b"
},
{
"comment": "('\\(int, int\\)' | None)",
"name": "support.type.property-name.transform.renpy",
"name": "support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy",
"match": "\\b(?<!\\.)(?:corner1|corner2)\\b"
},
{
"comment": "('\\(position, position\\)' | None)",
"name": "support.type.property-name.transform.renpy",
"name": "support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy",
"match": "\\b(?<!\\.)(?:xysize)\\b"
},
{
"comment": "('#string' | None)",
"name": "support.type.property-name.transform.renpy",
"name": "support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy",
"match": "\\b(?<!\\.)(?:fit)\\b"
},
{
Expand All @@ -94,26 +104,25 @@
},
{
"comment": "('#Matrix' | '#MatrixColor' | None)",
"name": "support.type.property-name.transform.renpy",
"name": "support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy",
"match": "\\b(?<!\\.)(?:matrixcolor)\\b"
},
{
"comment": "('#Matrix' | '#TransformMatrix' | None)",
"name": "support.type.property-name.transform.renpy",
"name": "support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy",
"match": "\\b(?<!\\.)(?:matrixtransform)\\b"
},
{
"comment": "('#bool' | '#float' | '\\(float, float, float\\)')",
"name": "support.type.property-name.transform.renpy",
"name": "support.type.property-name.transform.renpy entity.name.tag.css.transform.renpy",
"match": "\\b(?<!\\.)(?:perspective)\\b"
}
]
},
"atl-simple-expression": {
"patterns": [
{ "include": "source.renpy#expressions" },
{ "include": "source.renpy#renpy-only-expressions" },
{ "include": "#atl-build-in-properties" },
{ "include": "source.renpy.python#literal" },
{ "include": "source.renpy.python#member-access" },
{ "include": "source.renpy.python#illegal-operator" },
{ "include": "source.renpy.python#operator" },
Expand All @@ -132,7 +141,13 @@
{ "include": "source.renpy.python#special-variables" },
{ "include": "source.renpy.python#ellipsis" },
{ "include": "source.renpy.python#punctuation" },
{ "include": "source.renpy.python#line-continuation" }
{ "include": "source.renpy.python#line-continuation" },
{
"comment": "Tokenize identifiers",
"name": "variable.name.python",
"match": "\\b([[:alpha:]_]\\w*)\\b"
},
{ "include": "source.renpy#whitespace" }
]
},
"atl-expression": {
Expand Down Expand Up @@ -196,6 +211,10 @@
},
"end": "$",
"patterns": [{ "include": "#atl-expression" }]
},
{
"comment": "TODO: This is a temporary include until we have proper support for all ATL keywords",
"include": "source.renpy#keywords"
}
]
},
Expand Down Expand Up @@ -240,7 +259,7 @@
{ "include": "source.renpy.python#builtin-possible-callables" },
{ "include": "#atl-build-in-events" },
{
"name": "entity.name.function.renpy meta.function-call.generic.renpy",
"name": "entity.name.function.event.renpy meta.function-call.generic.renpy",
"match": "\\b([[:alpha:]_]\\w*)\\b"
}
]
Expand All @@ -250,7 +269,7 @@
{ "include": "source.renpy.python#builtin-possible-callables" },
{ "include": "#atl-build-in-events" },
{
"name": "entity.name.function.renpy",
"name": "entity.name.function.event.def.renpy",
"match": "\\b([[:alpha:]_]\\w*)\\b"
}
]
Expand Down Expand Up @@ -296,7 +315,7 @@
"patterns": [
{ "include": "source.renpy.python#builtin-possible-callables" },
{
"name": "entity.name.function.renpy meta.function-call.generic.renpy",
"name": "entity.name.function.atl-function.renpy meta.function-call.generic.renpy",
"match": "\\b([[:alpha:]_]\\w*)\\b"
}
]
Expand All @@ -314,20 +333,56 @@
{ "include": "#atl-build-in-warpers" },
{ "include": "#atl-build-in-properties" },
{
"name": "entity.name.function.renpy meta.function-call.generic.renpy",
"name": "entity.name.function.warper.renpy meta.function-call.generic.renpy",
"match": "\\b([[:alpha:]_]\\w*)\\b"
}
]
},
"atl-warper-broken": {
"comment": "TODO: This doesn't work right now, we can't assume all identifiers are warpers",
"name": "meta.atl.warper.renpy",
"begin": "(?<=^[ \\t]*)([[:alpha:]_]\\w*)\\b",
"beginCaptures": {
"1": { "patterns": [{ "include": "#atl-warper-name" }] }
},
"end": "(?=[ \\t]*#)|$",
"patterns": [{ "include": "#atl-simple-expression" }]
},

"atl-warper": {
"comment": "https://www.renpy.org/doc/html/atl.html#warpers",
"comment": "(TODO: For now we only support build-in warper highlighting) https://www.renpy.org/doc/html/atl.html#warpers",
"name": "meta.atl.warper.renpy",
"begin": "\\b(?<!\\.)([[:alpha:]_]\\w*)\\b[ \\t]*",
"begin": "(?<=^[ \\t]*)(linear|ease|easein|easeout|ease_back|ease_bounce|ease_circ|ease_cubic|ease_elastic|ease_expo|ease_quad|ease_quart|ease_quint|easein_back|easein_bounce|easein_circ|easein_cubic|easein_elastic|easein_expo|easein_quad|easein_quart|easein_quint|easeout_back|easeout_bounce|easeout_circ|easeout_cubic|easeout_elastic|easeout_expo|easeout_quad|easeout_quart|easeout_quint)\\b",
"beginCaptures": {
"1": { "patterns": [{ "include": "#atl-warper-name" }] }
},
"end": "(?!\\G)",
"end": "(?=[ \\t]*#)|$",
"patterns": [{ "include": "#atl-simple-expression" }]
},

"atl-fallback": {
"comment": "TODO: This is a temp fix for missing pattern references",
"patterns": [{ "include": "source.renpy" }]
},

"transform": {
"contentName": "meta.transform.block.renpy",
"begin": "^([ \\t]+)?(transform)\\b[ \\t]*(.*)?(:)",
"beginCaptures": {
"1": { "name": "punctuation.whitespace.leading.renpy" },
"2": { "name": "keyword.transform.renpy" },
"3": {
"patterns": [
{
"name": "variable.name.transform.renpy",
"match": "\\b([[:alpha:]_]\\w*)\\b"
}
]
},
"4": { "name": "punctuation.section.atl.begin.renpy" }
},
"end": "^(?=(?!\\1)[ \\t]*[^\\s#]|\\1[^\\s#])",
"patterns": [{ "include": "#atl" }]
}
}
}
2 changes: 2 additions & 0 deletions syntaxes/renpy.python.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@
},
"member-access": {
"name": "meta.member.access.python",
"contentName": "variable.name.python",
"begin": "(\\.)\\s*(?!\\.)",
"end": "(?<=\\S)(?=\\W)|(^|(?<=\\s))(?=[^\\\\\\w\\s])|$",
"beginCaptures": {
Expand Down Expand Up @@ -309,6 +310,7 @@
},
"odd-function-call": {
"comment": "A bit obscured function call where there may have been anarbitrary number of other operations to get the function.E.g. \"arr[idx](args)\"",
"name": "meta.odd-function-call.python",
"begin": "(?<=\\]|\\))\\s*(?=\\()",
"end": "(\\))",
"endCaptures": {
Expand Down
Loading

0 comments on commit 24c7cb5

Please sign in to comment.