Skip to content

Commit

Permalink
Full variable/property highlighting to grammar, void as keyword
Browse files Browse the repository at this point in the history
Better syntax highlighting for properties. Class variables used to be unhighlighted and are now highlighted properly as `variable.other.gdscript`, properties are still highlighted as `variable.other.property.gdscript`
  • Loading branch information
ryanabx committed Oct 19, 2023
1 parent 1054053 commit 211fbf3
Showing 1 changed file with 43 additions and 7 deletions.
50 changes: 43 additions & 7 deletions syntaxes/GDScript.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@
{
"include": "#any_method"
},
{
"include": "#any_variable"
},
{
"include": "#any_property"
},
Expand Down Expand Up @@ -375,14 +378,17 @@
]
},
"variable_definition": {
"begin": "\\b(?:(var)|(const))\\s+",
"begin": "\\b(?:(var)|(const))\\s+([a-zA-Z_]\\w*)\\s*",
"end": "$|;",
"beginCaptures": {
"1": {
"name": "storage.type.var.gdscript"
},
"2": {
"name": "storage.type.const.gdscript"
},
"3": {
"name": "variable.other.gdscript"
}
},
"patterns": [
Expand Down Expand Up @@ -417,6 +423,18 @@
},
{
"include": "#base_expression"
},
{
"include": "#letter"
},
{
"include": "#any_variable"
},
{
"include": "#any_property"
},
{
"include": "#keywords"
}
]
},
Expand Down Expand Up @@ -611,7 +629,7 @@
]
},
"annotations": {
"match": "(@)(export|export_color_no_alpha|export_dir|export_enum|export_exp_easing|export_file|export_flags|export_flags_2d_navigation|export_flags_2d_physics|export_flags_2d_render|export_flags_3d_navigation|export_flags_3d_physics|export_flags_3d_render|export_global_dir|export_global_file|export_multiline|export_node_path|export_placeholder|export_range|icon|onready|rpc|tool|warning_ignore)\\b",
"match": "(@)(export|export_color_no_alpha|export_dir|export_enum|export_exp_easing|export_file|export_flags|export_flags_2d_navigation|export_flags_2d_physics|export_flags_2d_render|export_flags_3d_navigation|export_flags_3d_physics|export_flags_3d_render|export_global_dir|export_global_file|export_multiline|export_node_path|export_placeholder|export_range|icon|onready|rpc|tool|warning_ignore|abstract)\\b",
"captures": {
"1": {
"name": "entity.name.function.decorator.gdscript"
Expand All @@ -623,15 +641,15 @@
},
"builtin_classes": {
"match": "(?<![^.]\\.|:)\\b(OS|GDScript|Vector2|Vector2i|Vector3|Vector3i|Color|Rect2|Rect2i|Array|Basis|Dictionary|Plane|Quat|RID|Rect3|Transform|Transform2D|Transform3D|AABB|String|Color|NodePath|Object|PoolByteArray|PoolIntArray|PoolRealArray|PoolStringArray|PoolVector2Array|PoolVector3Array|PoolColorArray|bool|int|float|StringName|Quaternion|PackedByteArray|PackedInt32Array|PackedInt64Array|PackedFloat32Array|PackedFloat64Array|PackedStringArray|PackedVector2Array|PackedVector2iArray|PackedVector3Array|PackedVector3iArray|PackedColorArray|super)\\b",
"name": "support.class.library.gdscript"
"name": "entity.name.type.class.builtin.gdscript"
},
"const_vars": {
"match": "\\b([A-Z_][A-Z_0-9]*)\\b",
"name": "constant.language.gdscript"
},
"pascal_case_class": {
"match": "\\b([A-Z][a-z_0-9]*([A-Z]?[a-z_0-9]+)*[A-Z]?)\\b",
"name": "support.class.library.gdscript"
"name": "entity.name.type.class.gdscript"
},
"signal_declaration_bare": {
"match": "(?x) \\s*\n (signal) \\s+\n ([a-zA-Z_]\\w*)(?=[\\n\\s])",
Expand Down Expand Up @@ -720,9 +738,11 @@
"include": "#line_continuation"
},
{
"match": "\\s*(\\-\\>)\\s*([a-zA-Z_]\\w*)\\s*\\:",
"match": "\\s*(?:\\-\\>)\\s*(void\\w*)|([a-zA-Z_]\\w*)\\s*\\:",
"captures": {
"1": {},
"1": {
"name": "keyword.language.void.gdscript"
},
"2": {
"name": "entity.name.type.class.gdscript"
}
Expand Down Expand Up @@ -852,8 +872,12 @@
"match": "\\b([A-Za-z_]\\w*)\\b(?=\\s*(?:[(]))",
"name": "support.function.any-method.gdscript"
},
"any_variable": {
"match": "\\b(?<![@\\$#%])([A-Za-z_]\\w*)\\b(?![(])",
"name": "variable.other.gdscript"
},
"any_property": {
"match": "(?<=[^.]\\.)\\b([A-Za-z_]\\w*)\\b(?![(])",
"match": "\\b\\.\\s*(?<![@\\$#%])([A-Za-z_]\\w*)\\b(?![(])",
"name": "variable.other.property.gdscript"
},
"function_call": {
Expand Down Expand Up @@ -932,6 +956,18 @@
"name": "punctuation.definition.arguments.begin.gdscript"
}
}
},
{
"include": "#letter"
},
{
"include": "#any_variable"
},
{
"include": "#any_property"
},
{
"include": "#keywords"
}
]
}
Expand Down

0 comments on commit 211fbf3

Please sign in to comment.