From 211fbf36ebcf5347ed9a9f4cae0e5ffc5eb6f9ea Mon Sep 17 00:00:00 2001 From: ryanabx Date: Thu, 12 Oct 2023 23:55:24 -0500 Subject: [PATCH] Full variable/property highlighting to grammar, `void` as keyword 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` --- syntaxes/GDScript.tmLanguage.json | 50 ++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/syntaxes/GDScript.tmLanguage.json b/syntaxes/GDScript.tmLanguage.json index 148e27c49..54997b0d2 100644 --- a/syntaxes/GDScript.tmLanguage.json +++ b/syntaxes/GDScript.tmLanguage.json @@ -93,6 +93,9 @@ { "include": "#any_method" }, + { + "include": "#any_variable" + }, { "include": "#any_property" }, @@ -375,7 +378,7 @@ ] }, "variable_definition": { - "begin": "\\b(?:(var)|(const))\\s+", + "begin": "\\b(?:(var)|(const))\\s+([a-zA-Z_]\\w*)\\s*", "end": "$|;", "beginCaptures": { "1": { @@ -383,6 +386,9 @@ }, "2": { "name": "storage.type.const.gdscript" + }, + "3": { + "name": "variable.other.gdscript" } }, "patterns": [ @@ -417,6 +423,18 @@ }, { "include": "#base_expression" + }, + { + "include": "#letter" + }, + { + "include": "#any_variable" + }, + { + "include": "#any_property" + }, + { + "include": "#keywords" } ] }, @@ -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" @@ -623,7 +641,7 @@ }, "builtin_classes": { "match": "(?)\\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" } @@ -852,8 +872,12 @@ "match": "\\b([A-Za-z_]\\w*)\\b(?=\\s*(?:[(]))", "name": "support.function.any-method.gdscript" }, + "any_variable": { + "match": "\\b(?