on master help sign in
Update queries for godot4 (#6186)
e6597bcErasin Wang
languages.toml+1−1
@@ -1463,7 +1463,7 @@ indent = { tab-width = 4, unit = "\t" }
1463
1463
1464[[grammar]]
1464[[grammar]]
1465name = "gdscript"
1465name = "gdscript"
1466−source = { git = "https://github.com/PrestonKnopp/tree-sitter-gdscript", rev = "a56a6fcec3fb63ec3324bf9373aae7298861eb30" }
1466+source = { git = "https://github.com/PrestonKnopp/tree-sitter-gdscript", rev = "a4b57cc3bcbfc24550e858159647e9238e7ad1ac" }
1467
1467
1468[[language]]
1468[[language]]
1469name = "godot-resource"
1469name = "godot-resource"
runtime/queries/gdscript/highlights.scm+61−27
@@ -1,7 +1,8 @@
1; Identifier naming conventions
1; Identifier naming conventions
2
2
3+(
3−((identifier) @constant
4+ (identifier) @constant
4− (#match? @constant "^[A-Z][A-Z_]*$"))
5+ (#match? @constant "^[A-Z][A-Z\\d_]+$"))
5
6
6; class
7; class
7(class_name_statement (name) @type)
8(class_name_statement (name) @type)
@@ -11,32 +12,35 @@
11; Function calls
12; Function calls
12
13
13(attribute_call (identifier) @function)
14(attribute_call (identifier) @function)
14−
15(base_call (identifier) @function)
15(base_call (identifier) @function)
16−
17(call (identifier) @function)
16(call (identifier) @function)
18
17
19; Function definitions
18; Function definitions
20
19
21(function_definition (name) @function)
20(function_definition (name) @function)
22−
23(constructor_definition "_init" @function)
21(constructor_definition "_init" @function)
24
22
23+
25;; Literals
24;; Literals
26−(integer) @constant.numeric.integer
27−(float) @constant.numeric.float
28(comment) @comment
25(comment) @comment
29(string) @string
26(string) @string
30−(escape_sequence) @constant.character.escape
27+
31−(identifier) @variable
32(type) @type
28(type) @type
29+(expression_statement (array (identifier) @type))
30+(binary_operator (identifier) @type)
33
31
34−;; Literals
32+(variable_statement (identifier) @variable)
33+(get_node) @label
34+
35+(const_statement (name) @constant)
36+(integer) @constant.numeric.integer
37+(float) @constant.numeric.float
38+(escape_sequence) @constant.character.escape
35[
39[
36 (true)
40 (true)
37 (false)
41 (false)
38− (null)
42+] @constant.builtin.boolean
39−] @constant.builtin
43+(null) @constant.builtin
40
44
41[
45[
42 "+"
46 "+"
@@ -62,37 +66,67 @@
62 "~"
66 "~"
63 "<<"
67 "<<"
64 ">>"
68 ">>"
65− "and"
66− "or"
67− "not"
68] @operator
69] @operator
69
70
71+(annotation (identifier) @keyword.storage.modifier)
72+
70[
73[
71− (static_keyword)
72− (remote_keyword)
73− (tool_statement)
74− "var"
75− "func"
76− "setget"
77− "in"
78− "is"
79− "as"
80 "if"
74 "if"
81 "else"
75 "else"
82 "elif"
76 "elif"
77+] @keyword.control.conditional
78+
79+[
83 "while"
80 "while"
84 "for"
81 "for"
82+] @keyword.control.repeat
83+
84+[
85 "return"
85 "return"
86+ "pass"
86 "break"
87 "break"
87 "continue"
88 "continue"
88− "pass"
89+] @keyword.control.return
90+
91+[
92+ "func"
93+] @keyword.control.function
94+
95+[
96+ "export"
97+] @keyword.control.import
98+
99+[
100+ "in"
101+ "is"
102+ "as"
89 "match"
103 "match"
104+ "and"
105+ "or"
106+ "not"
107+] @keyword.operator
108+
109+[
110+ "var"
90 "class"
111 "class"
91 "class_name"
112 "class_name"
92 "enum"
113 "enum"
114+] @keyword.storage.type
115+
116+
117+[
118+ (remote_keyword)
119+ (static_keyword)
120+ "const"
93 "signal"
121 "signal"
122+ "@"
123+] @keyword.storage.modifier
124+
125+[
126+ "setget"
94 "onready"
127 "onready"
95− "export"
96 "extends"
128 "extends"
97− "const"
129+ "set"
130+ "get"
98] @keyword
131] @keyword
132+
runtime/queries/gdscript/indents.scm+1−1
@@ -12,6 +12,7 @@
12
12
13 (dictionary (_))
13 (dictionary (_))
14 (array (_))
14 (array (_))
15+ (setget)
15] @indent
16] @indent
16
17
17[
18[
@@ -25,7 +26,6 @@
25 (class_definition)
26 (class_definition)
26] @extend
27] @extend
27
28
28−
29[
29[
30 (return_statement)
30 (return_statement)
31 (break_statement)
31 (break_statement)
runtime/queries/godot-resource/injections.scm+16
@@ -1,2 +1,18 @@
1((comment) @injection.content
1((comment) @injection.content
2 (#set! injection.language "comment"))
2 (#set! injection.language "comment"))
3+
4+; ((section) @injection.content
5+; (#set! injection.language "comment"))
6+
7+((section
8+ (attribute
9+ (identifier) @_type
10+ (string) @_is_shader)
11+ (property
12+ (path) @_is_code
13+ (string) @injection.content))
14+ (#match? @_type "type")
15+ (#match? @_is_shader "Shader")
16+ (#eq? @_is_code "code")
17+ (#set! injection.language "glsl")
18+)