From 70ec8c24036210241aa16060c762d2b3ba2bb937 Mon Sep 17 00:00:00 2001 From: "Dev.Sharbel" <136091602+Dev-Sharbel@users.noreply.github.com> Date: Mon, 2 Feb 2026 02:43:00 +0200 Subject: [PATCH 1/5] Enhance GDScript syntax highlighting rules Refined Scope Mappings: Grouped keywords like var, const, if, for, setget, and @export under appropriate standard scopes (@keyword.storage, @keyword.control, @attribute). Parameter Scoping: Function and lambda parameters now use the specific @variable.parameter scope, separating them from general local variables. Literal Consistency: null, true, false, PI, TAU, etc., are correctly grouped under @constant.builtin. Comment Annotations: Added specific regex matches for comment keywords (TODO, FIXME, ALERT, NOTE) using standard @error, @warning, and @info scopes. (Articulated this description with AI) --- languages/gdscript/highlights.scm | 85 +++++++++++++++++++++++-------- 1 file changed, 63 insertions(+), 22 deletions(-) diff --git a/languages/gdscript/highlights.scm b/languages/gdscript/highlights.scm index 85af806..0d35a4d 100644 --- a/languages/gdscript/highlights.scm +++ b/languages/gdscript/highlights.scm @@ -13,9 +13,9 @@ (function_definition name: (name) @function - parameters: (parameters) @variable) + parameters: (parameters) @variable.parameter) (constructor_definition "_init" @function) -(lambda (parameters) @variable) +(lambda (parameters) @variable.parameter) ;; Literals @@ -26,12 +26,24 @@ (region_start) (region_end) ] @comment.doc + +; Critical comment +((comment) @error + (#match? @error "\\b(ALERT|ATTENTION|CAUTION|CRITICAL|DANGER|SECURITY)\\b")) + +; Warning comment +((comment) @warning + (#match? @warning "\\b(BUG|DEPRECATED|FIXME|HACK|TASK|TBD|TODO|WARNING)\\b")) + +; Info comment +((comment) @info + (#match? @info "\\b(INFO|NOTE|NOTICE|TEST|TESTING)\\b")) + (string) @string (type) @type (enum_definition (name) @type) (enumerator (identifier) @variant) -(null) @type (variable_statement (identifier) @variable) (attribute @@ -57,9 +69,14 @@ (escape_sequence) @string.escape [ + "PI" + "TAU" + "NAN" + "INF" + (null) (true) (false) -] @boolean +] @constant.builtin [ "+" @@ -100,12 +117,19 @@ ; Keywords (annotation (identifier) @keyword) +; Storage [ - (remote_keyword) - (static_keyword) - (breakpoint_statement) -] @keyword + "var" + "const" + "signal" + "enum" + "static" +] @keyword.storage + +; Function +"func" @keyword.function +; Action [ "if" "else" @@ -114,29 +138,46 @@ "while" "for" "return" - "pass" "break" "continue" - "func" - "in" - "is" - "as" + "await" + "pass" + "breakpoint" + "yield" +] @keyword.control + +; Operator +[ "and" "or" "not" - "var" - "class" - "class_name" - "enum" - "const" - "signal" + "in" + "is" + "as" +] @keyword.operator + +; Attribute +[ "@" - "setget" + "export" "onready" - "extends" + "tool" + "setget" "set" "get" - "await" +] @attribute + +; Import +[ + "preload" + "load" +] @keyword.import + +; Remaining Keywords +[ + "class" + "class_name" + "extends" ] @keyword ((identifier) @keyword From 6bbd243d39bcabf0fe6b03d68564ebb95eac7803 Mon Sep 17 00:00:00 2001 From: Fuzzycc-local1 <70171293+Fuzzycc@users.noreply.github.com> Date: Tue, 3 Feb 2026 03:28:25 +0200 Subject: [PATCH 2/5] fixed highlights.scm, now works well diversified some keywords and changed the type of other to better reflect what Godot uses --- languages/gdscript/highlights.scm | 35 ++++++++++++++----------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/languages/gdscript/highlights.scm b/languages/gdscript/highlights.scm index 0d35a4d..e8611df 100644 --- a/languages/gdscript/highlights.scm +++ b/languages/gdscript/highlights.scm @@ -5,14 +5,14 @@ ; Function calls -(attribute_call (identifier) @function) -(base_call (identifier) @function) +(attribute_call (identifier) @function.method) +(base_call (identifier) @function.builtin) (call (identifier) @function) ; Function definitions (function_definition - name: (name) @function + name: (name) @function.definition parameters: (parameters) @variable.parameter) (constructor_definition "_init" @function) (lambda (parameters) @variable.parameter) @@ -25,7 +25,7 @@ [ (region_start) (region_end) -] @comment.doc +] @tag ; Critical comment ((comment) @error @@ -68,11 +68,10 @@ ] @number (escape_sequence) @string.escape + +((identifier) @constant.builtin + (#match? @constant.builtin "^(PI|TAU|NAN|INF)$")) [ - "PI" - "TAU" - "NAN" - "INF" (null) (true) (false) @@ -115,7 +114,9 @@ ] @operator ; Keywords -(annotation (identifier) @keyword) + +; Annotations +(annotation (identifier) @attribute) ; Storage [ @@ -123,7 +124,7 @@ "const" "signal" "enum" - "static" + (static_keyword) ] @keyword.storage ; Function @@ -142,8 +143,7 @@ "continue" "await" "pass" - "breakpoint" - "yield" + (breakpoint_statement) ] @keyword.control ; Operator @@ -159,19 +159,16 @@ ; Attribute [ "@" - "export" - "onready" - "tool" + ; "export" covered in Annotations above (@ followed by anything) + ; "onready" "setget" "set" "get" ] @attribute ; Import -[ - "preload" - "load" -] @keyword.import +((identifier) @keyword.import + (#match? @keyword.import "^(load|preload)$")) ; Remaining Keywords [ From 4b4f76e35251a281360ec06d25f7f0f31626a9ba Mon Sep 17 00:00:00 2001 From: Fuzzycc-local1 <70171293+Fuzzycc@users.noreply.github.com> Date: Wed, 4 Feb 2026 03:36:30 +0200 Subject: [PATCH 3/5] Update highlights.scm diversified strings (StringName, NodePath, etc.), but there is no way to color formatters like %s without coloring the entire string, so left that out. fixed variable names only coloring in declaration and not statements. Added a catchall at the top for that matching to @variable, doing similar work to godot's text color. added colon to operator list for consistency when static typing changed self and super to standard variable.language --- languages/gdscript/highlights.scm | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/languages/gdscript/highlights.scm b/languages/gdscript/highlights.scm index e8611df..341abb5 100644 --- a/languages/gdscript/highlights.scm +++ b/languages/gdscript/highlights.scm @@ -1,3 +1,10 @@ +; Any uncovered text, +; var a = 10 has 'a' matching @variable +; but a = 10 has 'a matching nothing. +; This is to keep consistency, and is like 'text_editor/theme/highlighting/text_color' in Godot Editor Settings +(identifier) @variable + + ; Class (class_name_statement (name) @type) (class_definition (name) @type) @@ -41,11 +48,19 @@ (string) @string +; currently no differentiation between built-in types (int, Vector2), and custom ones (with class_name) (type) @type (enum_definition (name) @type) (enumerator (identifier) @variant) -(variable_statement (identifier) @variable) +; Catch the name in a 'var' declaration +(variable_statement + name: (name) @variable) + +; Catch the name in a 'var' declaration with a type hint (like dirs: Dictionary) +(variable_statement + name: (name) @variable + type: (type)) (attribute (identifier) (identifier) @property) @@ -53,11 +68,9 @@ ((identifier) @type (#match? @type "^(bool|float|int)$")) -[ - (string_name) - (node_path) - (get_node) -] @label +(string_name) @string.special.symbol +(node_path) @string.special.path +(get_node) @string.special (signal_statement (name) @label) (const_statement (name) @constant) @@ -111,6 +124,7 @@ "<<=" ">>=" "**=" + ":" ; for consistency (to make :type= same as :=) ] @operator ; Keywords @@ -177,8 +191,8 @@ "extends" ] @keyword -((identifier) @keyword - (#match? @keyword "^(self|super)$")) +((identifier) @variable.language + (#match? @variable.language "^(self|super)$")) ; Identifier naming conventions ; This needs to be at the very end in order to override earlier queries From 89ea892edf4f998959936882249e8c8432f4334c Mon Sep 17 00:00:00 2001 From: Fuzzycc-local1 <70171293+Fuzzycc@users.noreply.github.com> Date: Wed, 4 Feb 2026 21:24:07 +0200 Subject: [PATCH 4/5] Update highlights.scm updated function_definition, now parameters, both typed and untyped will colored, in normal function definitions and in lambdas. --- languages/gdscript/highlights.scm | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/languages/gdscript/highlights.scm b/languages/gdscript/highlights.scm index 341abb5..45ccea9 100644 --- a/languages/gdscript/highlights.scm +++ b/languages/gdscript/highlights.scm @@ -11,19 +11,24 @@ ; Function calls - (attribute_call (identifier) @function.method) (base_call (identifier) @function.builtin) (call (identifier) @function) ; Function definitions - (function_definition - name: (name) @function.definition - parameters: (parameters) @variable.parameter) -(constructor_definition "_init" @function) -(lambda (parameters) @variable.parameter) - + name: (name) @function.definition) +; Constructor definition +(function_definition + name: (name) @constructor + (#eq? @constructor "_init")) +; Untyped function parameter defintiion: a in func foo(a) +(parameters (identifier) @variable.parameter) +; Typed function parameter defition: b in func foo(b: int) +(parameters + (typed_parameter + . (identifier) @variable.parameter)) +; both of the above work with lambdas too! ;; Literals (comment) @comment From 6dd6fc98668ae0d51388fd0a5c2f3a0b2e76ddb7 Mon Sep 17 00:00:00 2001 From: Fuzzycc-local1 <70171293+Fuzzycc@users.noreply.github.com> Date: Mon, 9 Feb 2026 03:20:28 +0200 Subject: [PATCH 5/5] update highlights.scm CHANGED signal definition to be under variable.special --- languages/gdscript/highlights.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages/gdscript/highlights.scm b/languages/gdscript/highlights.scm index 45ccea9..866952b 100644 --- a/languages/gdscript/highlights.scm +++ b/languages/gdscript/highlights.scm @@ -76,7 +76,7 @@ (string_name) @string.special.symbol (node_path) @string.special.path (get_node) @string.special -(signal_statement (name) @label) +(signal_statement (name) @variable.special) (const_statement (name) @constant)