Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved GDScript.tmLanguage.json #740

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 44 additions & 21 deletions syntaxes/GDScript.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@
]
},
"extends_statement": {
"name": "entity.other.inherited-class.gdscript",
"match": "(extends)\\s+([a-zA-Z_]\\w*\\.[a-zA-Z_]\\w*)?",
"captures": {
"1": { "name": "keyword.language.gdscript" },
"2": { "name": "entity.other.inherited-class.gdscript" }
"1": { "name": "entity.other.inherited-class.gdscript" },
"2": { "name": "keyword.language.gdscript" }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly is the intention here?

}
},
"expression": {
Expand All @@ -43,6 +44,7 @@
{ "include": "#builtin_classes" },
{ "include": "#class_new" },
{ "include": "#class_is" },
{ "include": "#class_as" },
{ "include": "#class_enum" },
{ "include": "#any_method" },
{ "include": "#any_variable" },
Expand Down Expand Up @@ -74,10 +76,12 @@
{ "include": "#square_braces" },
{ "include": "#round_braces" },
{ "include": "#function_call" },
{ "include": "#comment" },
{ "include": "#self" },
{ "include": "#func" },
{ "include": "#letter" },
{ "include": "#region" },
{ "include": "#endregion" },
{ "include": "#comment" },
{ "include": "#numbers" },
{ "include": "#pascal_case_class" },
{ "include": "#line_continuation" }
Expand Down Expand Up @@ -190,7 +194,7 @@
"patterns": [
{
"match": "\\bin\\b",
"name": "keyword.control.gdscript"
"name": "keyword.control.in.gdscript"
},
{ "include": "#base_expression" },
{ "include": "#any_variable" },
Expand Down Expand Up @@ -250,7 +254,15 @@
},
"letter": {
"match": "\\b(?:true|false|null)\\b",
"name": "constant.language.gdscript"
"name": "constant.language.boolean.gdscript"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null isn't a boolean, so this is actually less accurate than it was before.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right it was for the highlighting. This should be separated.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

constant.language and constant.language.boolean appear to be highlighted the same, so I don't know what you mean here.

},
"region": {
"match": "#region\\s+([a-zA-Z_]\\w*)",
"name": "keyword.preprocessor.region.gdscript"
},
"endregion": {
"match": "#endregion",
"name": "keyword.preprocessor.endregion.gdscript"
},
"numbers": {
"patterns": [
Expand Down Expand Up @@ -302,10 +314,10 @@
"name": "keyword.operator.assignment.gdscript"
},
{
"match": "(:)\\s*([a-zA-Z_]\\w*)?",
"match": "(:)\\s*\\b(int|float|bool)\\b",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rule needs to match any valid type, why did you change it to int|float|bool?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because in Godot the 3 vars are highlighted separated than others. I not sure if more vars types are like this 3.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like Godot is wrong, then.

"captures": {
"1": { "name": "punctuation.separator.annotation.gdscript" },
"2": { "name": "entity.name.type.class.gdscript" }
"2": { "name": "entity.name.type.variable.gdscript" }
}
},
{
Expand Down Expand Up @@ -363,11 +375,18 @@
"2": { "name": "entity.name.type.class.gdscript" }
}
},
"class_as": {
"match": "\\s+(as)\\s+([a-zA-Z_]\\w*)",
"captures": {
"1": { "name": "storage.type.as.gdscript" },
"2": { "name": "entity.name.type.class.gdscript" }
}
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foo as class is already highlighted correctly as far as I can tell, so what is the purpose of this rule?

"class_enum": {
"match": "\\b([A-Z][a-zA-Z_0-9]*)\\.([A-Z_0-9]+)",
"captures": {
"1": { "name": "entity.name.type.class.gdscript" },
"2": { "name": "variable.other.enummember.gdscript" }
"2": { "name": "constant.language.gdscript" }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is overwriting a change that was just merged in #737, please revert this.

}
},
"class_name": {
Expand Down Expand Up @@ -403,46 +422,50 @@
"name": "meta.literal.nodepath.bare.gdscript",
"match": "(?<!/\\s*)(\\$\\s*|%|\\$%\\s*)(/\\s*)?([a-zA-Z_]\\w*)\\b(?!\\s*/)",
"captures": {
"1": { "name": "keyword.control.flow.gdscript" },
"2": { "name": "constant.character.escape.gdscript" },
"3": { "name": "constant.character.escape.gdscript" },
"4": { "name": "constant.character.escape.gdscript" }
"1": { "name": "keyword.control.flow.nodepath.gdscript" },
"2": { "name": "constant.character.escape.nodepath.gdscript" },
"3": { "name": "constant.character.escape.nodepath.gdscript" },
"4": { "name": "constant.character.escape.nodepath.gdscript" }
}
},
"builtin_get_node_shorthand_bare_multi": {
"name": "meta.literal.nodepath.bare.gdscript",
"begin": "(\\$\\s*|%|\\$%\\s*)(/\\s*)?([a-zA-Z_]\\w*)",
"beginCaptures": {
"1": { "name": "keyword.control.flow.gdscript" },
"2": { "name": "constant.character.escape.gdscript" },
"3": { "name": "constant.character.escape.gdscript" }
"1": { "name": "keyword.control.flow.nodepath.gdscript" },
"2": { "name": "constant.character.escape.nodepath.gdscript" },
"3": { "name": "constant.character.escape.nodepath.gdscript" }
},
"end": "(?!\\s*/\\s*%?\\s*[a-zA-Z_]\\w*)",
"patterns": [
{
"match": "(/)\\s*(%)?\\s*([a-zA-Z_]\\w*)\\s*",
"captures": {
"1": { "name": "constant.character.escape.gdscript" },
"2": { "name": "keyword.control.flow.gdscript" },
"3": { "name": "constant.character.escape.gdscript" }
"1": { "name": "constant.character.escape.nodepath.gdscript" },
"2": { "name": "keyword.control.flow.nodepath.gdscript" },
"3": { "name": "constant.character.escape.nodepath.gdscript" }
}
}
]
},
"annotations": {
"match": "(@)(export|export_color_no_alpha|export_custom|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|export_storage|icon|onready|rpc|tool|warning_ignore|abstract|static_unload)\\b",
"match": "(@)(export|export_color_no_alpha|export_custom|export_category|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|export_storage|icon|onready|rpc|tool|warning_ignore|abstract)\\b",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static_unload was just added in #738, and you're removing it here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I didn't see static_unload because when i push the first changes it wasn't. You are right.

"captures": {
"1": { "name": "entity.name.function.decorator.gdscript" },
"2": { "name": "entity.name.function.decorator.gdscript" }
}
},
"builtin_classes": {
"match": "(?<![^.]\\.|:)\\b(Vector2|Vector2i|Vector3|Vector3i|Vector4|Vector4i|Color|Rect2|Rect2i|Array|Basis|Dictionary|Plane|Quat|RID|Rect3|Transform|Transform2D|Transform3D|AABB|String|Color|NodePath|PoolByteArray|PoolIntArray|PoolRealArray|PoolStringArray|PoolVector2Array|PoolVector3Array|PoolColorArray|bool|int|float|Signal|Callable|StringName|Quaternion|Projection|PackedByteArray|PackedInt32Array|PackedInt64Array|PackedFloat32Array|PackedFloat64Array|PackedStringArray|PackedVector2Array|PackedVector2iArray|PackedVector3Array|PackedVector3iArray|PackedVector4Array|PackedColorArray|super)\\b",
"match": "(?<![^.]\\.|:)\\b(Vector2|Vector2i|Vector3|Vector3i|Color|Rect2|Rect2i|Array|Basis|Dictionary|Plane|Quat|RID|Rect3|Transform|Transform2D|Transform3D|AABB|String|Color|NodePath|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",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is removing several types that were added in #738.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same of the previous comment.

"name": "entity.name.type.class.builtin.gdscript"
},
"keyword_type_float": {
"match": "(?<![^.]\\.|:)\\b(float)\\b",
"name": "keyword.type.float.gdscript"
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

float is a type, not a keyword, so I don't know what this rule is supposed to achieve.

This rule also does not appear to be included anywhere, so it's not even doing anything.

"const_vars": {
"match": "\\b([A-Z_][A-Z_0-9]*)\\b",
"name": "variable.other.constant.gdscript"
"name": "constant.language.gdscript"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is overwriting a change that was just made in #737.

},
"pascal_case_class": {
"match": "\\b([A-Z]+[a-z_0-9]*([A-Z]?[a-z_0-9]+)*[A-Z]?)\\b",
Expand Down