From 207f90f01bb8593b6bccd36752d2844d84e6c765 Mon Sep 17 00:00:00 2001 From: Chetan Date: Sun, 23 Mar 2025 13:24:30 +0000 Subject: [PATCH 1/5] Add GDScript submodule and syntax test file for GDScript support, see #XXX (@chetanjangir0) --- .gitmodules | 3 + CHANGELOG.md | 1 + assets/syntaxes/02_Extra/GDScript-sublime | 1 + tests/syntax-tests/source/GDScript/test.gd | 71 ++++++++++++++++++++++ 4 files changed, 76 insertions(+) create mode 160000 assets/syntaxes/02_Extra/GDScript-sublime create mode 100644 tests/syntax-tests/source/GDScript/test.gd diff --git a/.gitmodules b/.gitmodules index fe3df9a2..f51cea4f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -266,3 +266,6 @@ [submodule "assets/syntaxes/02_Extra/Idris2"] path = assets/syntaxes/02_Extra/Idris2 url = https://github.com/buzden/sublime-syntax-idris2 +[submodule "assets/syntaxes/02_Extra/GDScript-sublime"] + path = assets/syntaxes/02_Extra/GDScript-sublime + url = https://github.com/beefsack/GDScript-sublime diff --git a/CHANGELOG.md b/CHANGELOG.md index b4a8184c..fca20b2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ - Map `ndjson` extension to JSON syntax, see #3209 (@keith-hall) - Map files with `csproj`, `vbproj`, `props` and `targets` extensions to XML syntax, see #3213 (@keith-hall) - Add debsources syntax to highlight `/etc/apt/sources.list` files, see #3215 (@keith-hall) +- Add syntax test file for GDScript highlighting, see #XYZ (@chetanjangir0) ## Themes diff --git a/assets/syntaxes/02_Extra/GDScript-sublime b/assets/syntaxes/02_Extra/GDScript-sublime new file mode 160000 index 00000000..96f5dcf2 --- /dev/null +++ b/assets/syntaxes/02_Extra/GDScript-sublime @@ -0,0 +1 @@ +Subproject commit 96f5dcf29728aa987123321e2544330eed991a3e diff --git a/tests/syntax-tests/source/GDScript/test.gd b/tests/syntax-tests/source/GDScript/test.gd new file mode 100644 index 00000000..7192dfec --- /dev/null +++ b/tests/syntax-tests/source/GDScript/test.gd @@ -0,0 +1,71 @@ +extends Node + +signal custom_signal(param) + +const PI = 3.14159 + +var untyped_var = "Hello, World!" +var typed_int: int = 42 +var typed_float: float = 3.14 +var typed_string: String = "GDScript Test" +var typed_array: Array = [1, 2, 3, 4] +var typed_dict: Dictionary = {"key": "value", "number": 100} + +onready var label = $Label + +func say_hello() -> void: + print("Hello from GDScript!") + +func add_numbers(a: int, b: int = 10) -> int: + return a + b + +func process_value(value: int) -> String: + if value < 0: + return "Negative" + elif value == 0: + return "Zero" + else: + return "Positive" + +func sum_array(arr: Array) -> int: + var total: int = 0 + for num in arr: + total += num + return total + +func describe_number(num: int) -> String: + match num: + 0: + return "Zero" + 1, 2, 3: + return "Small number" + _: + return "Large number" + +func long_description() -> String: + return """This is a test file for GDScript. +It covers variables, functions, control structures, loops, signals, inner classes, +multiline strings, arrays, and dictionaries.""" + +class InnerExample: + var inner_value: int = 99 + func show_value() -> void: + print("Inner value is:", inner_value) + +func test_inner_class() -> void: + var inner = InnerExample.new() + inner.show_value() + +func trigger_signal() -> void: + emit_signal("custom_signal", "TestParam") + +func _ready() -> void: + say_hello() + var result_add = add_numbers(5) + print("Add result:", result_add) + print("Process value for -5:", process_value(-5)) + print("Sum of array [10, 20, 30]:", sum_array([10, 20, 30])) + print("Description for 2:", describe_number(2)) + print("Long description:\n", long_description()) + test_inner_class() + trigger_signal() From 4175f289796af56ea251d04ae621ef8053706c44 Mon Sep 17 00:00:00 2001 From: Chetan Date: Sun, 23 Mar 2025 13:53:32 +0000 Subject: [PATCH 2/5] Update changelog entry for GDScript support (#3233) --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fca20b2b..08503047 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ - Map `ndjson` extension to JSON syntax, see #3209 (@keith-hall) - Map files with `csproj`, `vbproj`, `props` and `targets` extensions to XML syntax, see #3213 (@keith-hall) - Add debsources syntax to highlight `/etc/apt/sources.list` files, see #3215 (@keith-hall) -- Add syntax test file for GDScript highlighting, see #XYZ (@chetanjangir0) +- Add syntax test file for GDScript highlighting, see #3236 (@chetanjangir0) ## Themes From 3eef8590f43f1c0e052f0a31e29f603d30afd90d Mon Sep 17 00:00:00 2001 From: chetanjangir0 Date: Sat, 12 Apr 2025 18:00:43 +0530 Subject: [PATCH 3/5] genereated highlighted syntax test file --- .../syntax-tests/highlighted/GDScript/test.gd | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/syntax-tests/highlighted/GDScript/test.gd diff --git a/tests/syntax-tests/highlighted/GDScript/test.gd b/tests/syntax-tests/highlighted/GDScript/test.gd new file mode 100644 index 00000000..99c64412 --- /dev/null +++ b/tests/syntax-tests/highlighted/GDScript/test.gd @@ -0,0 +1,71 @@ +extends Node + +signal custom_signal(param) + +const PI = 3.14159 + +var untyped_var = "Hello, World!" +var typed_int: int = 42 +var typed_float: float = 3.14 +var typed_string: String = "GDScript Test" +var typed_array: Array = [1, 2, 3, 4] +var typed_dict: Dictionary = {"key": "value", "number": 100} + +onready var label = $Label + +func say_hello() -> void: + print("Hello from GDScript!") + +func add_numbers(a: int, b: int = 10) -> int: + return a + b + +func process_value(value: int) -> String: + if value < 0: + return "Negative" + elif value == 0: + return "Zero" + else: + return "Positive" + +func sum_array(arr: Array) -> int: + var total: int = 0 + for num in arr: + total += num + return total + +func describe_number(num: int) -> String: + match num: + 0: + return "Zero" + 1, 2, 3: + return "Small number" + _: + return "Large number" + +func long_description() -> String: + return """This is a test file for GDScript. +It covers variables, functions, control structures, loops, signals, inner classes, +multiline strings, arrays, and dictionaries.""" + +class InnerExample: + var inner_value: int = 99 + func show_value() -> void: + print("Inner value is:", inner_value) + +func test_inner_class() -> void: + var inner = InnerExample.new() + inner.show_value() + +func trigger_signal() -> void: + emit_signal("custom_signal", "TestParam") + +func _ready() -> void: + say_hello() + var result_add = add_numbers(5) + print("Add result:", result_add) + print("Process value for -5:", process_value(-5)) + print("Sum of array [10, 20, 30]:", sum_array([10, 20, 30])) + print("Description for 2:", describe_number(2)) + print("Long description:\n", long_description()) + test_inner_class() + trigger_signal() From 14064dd987413ac3ff0b19eecdb0f9d7b346ae93 Mon Sep 17 00:00:00 2001 From: chetanjangir0 Date: Sat, 12 Apr 2025 19:14:15 +0530 Subject: [PATCH 4/5] regenerated the highlighted file --- .../syntax-tests/highlighted/GDScript/test.gd | 112 +++++++++--------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/tests/syntax-tests/highlighted/GDScript/test.gd b/tests/syntax-tests/highlighted/GDScript/test.gd index 99c64412..4ea498cf 100644 --- a/tests/syntax-tests/highlighted/GDScript/test.gd +++ b/tests/syntax-tests/highlighted/GDScript/test.gd @@ -1,71 +1,71 @@ -extends Node +extends Node -signal custom_signal(param) +signal custom_signal(param) -const PI = 3.14159 +const PI = 3.14159 -var untyped_var = "Hello, World!" -var typed_int: int = 42 -var typed_float: float = 3.14 -var typed_string: String = "GDScript Test" -var typed_array: Array = [1, 2, 3, 4] -var typed_dict: Dictionary = {"key": "value", "number": 100} +var untyped_var = "Hello, World!" +var typed_int: int = 42 +var typed_float: float = 3.14 +var typed_string: String = "GDScript Test" +var typed_array: Array = [1, 2, 3, 4] +var typed_dict: Dictionary = {"key": "value", "number": 100} -onready var label = $Label +onready var label = $Label -func say_hello() -> void: - print("Hello from GDScript!") +func say_hello() -> void: + print("Hello from GDScript!") -func add_numbers(a: int, b: int = 10) -> int: - return a + b +func add_numbers(a: int, b: int = 10) -> int: + return a + b -func process_value(value: int) -> String: - if value < 0: - return "Negative" - elif value == 0: - return "Zero" - else: - return "Positive" +func process_value(value: int) -> String: + if value < 0: + return "Negative" + elif value == 0: + return "Zero" + else: + return "Positive" -func sum_array(arr: Array) -> int: - var total: int = 0 - for num in arr: - total += num - return total +func sum_array(arr: Array) -> int: + var total: int = 0 + for num in arr: + total += num + return total -func describe_number(num: int) -> String: - match num: - 0: - return "Zero" - 1, 2, 3: - return "Small number" +func describe_number(num: int) -> String: + match num: + 0: + return "Zero" + 1, 2, 3: + return "Small number"  _: - return "Large number" + return "Large number" -func long_description() -> String: - return """This is a test file for GDScript. -It covers variables, functions, control structures, loops, signals, inner classes, -multiline strings, arrays, and dictionaries.""" +func long_description() -> String: + return """This is a test file for GDScript. +It covers variables, functions, control structures, loops, signals, inner classes, +multiline strings, arrays, and dictionaries.""" -class InnerExample: - var inner_value: int = 99 - func show_value() -> void: - print("Inner value is:", inner_value) +class InnerExample: + var inner_value: int = 99 + func show_value() -> void: + print("Inner value is:", inner_value) -func test_inner_class() -> void: - var inner = InnerExample.new() - inner.show_value() +func test_inner_class() -> void: + var inner = InnerExample.new() + inner.show_value() -func trigger_signal() -> void: - emit_signal("custom_signal", "TestParam") +func trigger_signal() -> void: + emit_signal("custom_signal", "TestParam") -func _ready() -> void: - say_hello() - var result_add = add_numbers(5) - print("Add result:", result_add) - print("Process value for -5:", process_value(-5)) - print("Sum of array [10, 20, 30]:", sum_array([10, 20, 30])) - print("Description for 2:", describe_number(2)) - print("Long description:\n", long_description()) - test_inner_class() - trigger_signal() +func _ready() -> void: + say_hello() + var result_add = add_numbers(5) + print("Add result:", result_add) + print("Process value for -5:", process_value(-5)) + print("Sum of array [10, 20, 30]:", sum_array([10, 20, 30])) + print("Description for 2:", describe_number(2)) + print("Long description:\n", long_description()) + test_inner_class() + trigger_signal() From 0bf4753ff10529912e424c3f5b6620fe614261f8 Mon Sep 17 00:00:00 2001 From: Chetan Jangir <69336404+chetanjangir0@users.noreply.github.com> Date: Sun, 13 Apr 2025 14:51:53 +0530 Subject: [PATCH 5/5] Update CHANGELOG.md Co-authored-by: Keith Hall --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 056cc71a..5f679045 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,7 @@ - Map `ndjson` extension to JSON syntax, see #3209 (@keith-hall) - Map files with `csproj`, `vbproj`, `props` and `targets` extensions to XML syntax, see #3213 (@keith-hall) - Add debsources syntax to highlight `/etc/apt/sources.list` files, see #3215 (@keith-hall) -- Add syntax test file for GDScript highlighting, see #3236 (@chetanjangir0) +- Add syntax definition and test file for GDScript highlighting, see #3236 (@chetanjangir0) - Add syntax test file for Odin highlighting, see #3241 (@chetanjangir0) ## Themes