on master help sign in
Update queries for godot4 (#6186)
commite6597bc9927c73800d31d4a45dc695a4abe77ec8 authorErasin Wang <erasinoo@gmail.com> dateMon 6 Mar 2023, 02:41 (4 years ago) parentdef2696
4 files changed+79−29
languages.toml+1−1 runtime/queries/gdscript/highlights.scm+61−27 runtime/queries/gdscript/indents.scm+1−1 runtime/queries/godot-resource/injections.scm+16
languages.toml+1−1
@@ -1463,7 +1463,7 @@ indent = { tab-width = 4, unit = "\t" }
14631463
14641464[[grammar]]
14651465name = "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" }
14671467
14681468[[language]]
14691469name = "godot-resource"
runtime/queries/gdscript/highlights.scm+61−27
@@ -1,7 +1,8 @@
11; Identifier naming conventions
22
3−((identifier) @constant
4− (#match? @constant "^[A-Z][A-Z_]*$"))
3+(
4+ (identifier) @constant
5+ (#match? @constant "^[A-Z][A-Z\\d_]+$"))
56
67; class
78(class_name_statement (name) @type)
@@ -11,32 +12,35 @@
1112; Function calls
1213
1314(attribute_call (identifier) @function)
14−
1515(base_call (identifier) @function)
16−
1716(call (identifier) @function)
1817
1918; Function definitions
2019
2120(function_definition (name) @function)
22−
2321(constructor_definition "_init" @function)
2422
23+
2524;; Literals
26−(integer) @constant.numeric.integer
27−(float) @constant.numeric.float
2825(comment) @comment
2926(string) @string
30−(escape_sequence) @constant.character.escape
31−(identifier) @variable
27+
3228(type) @type
29+(expression_statement (array (identifier) @type))
30+(binary_operator (identifier) @type)
3331
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
3539[
3640 (true)
3741 (false)
38− (null)
39−] @constant.builtin
42+] @constant.builtin.boolean
43+(null) @constant.builtin
4044
4145[
4246 "+"
@@ -62,37 +66,67 @@
6266 "~"
6367 "<<"
6468 ">>"
65− "and"
66− "or"
67− "not"
6869] @operator
6970
71+(annotation (identifier) @keyword.storage.modifier)
72+
7073[
71− (static_keyword)
72− (remote_keyword)
73− (tool_statement)
74− "var"
75− "func"
76− "setget"
77− "in"
78− "is"
79− "as"
8074 "if"
8175 "else"
8276 "elif"
77+] @keyword.control.conditional
78+
79+[
8380 "while"
8481 "for"
82+] @keyword.control.repeat
83+
84+[
8585 "return"
86+ "pass"
8687 "break"
8788 "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"
89103 "match"
104+ "and"
105+ "or"
106+ "not"
107+] @keyword.operator
108+
109+[
110+ "var"
90111 "class"
91112 "class_name"
92113 "enum"
114+] @keyword.storage.type
115+
116+
117+[
118+ (remote_keyword)
119+ (static_keyword)
120+ "const"
93121 "signal"
122+ "@"
123+] @keyword.storage.modifier
124+
125+[
126+ "setget"
94127 "onready"
95− "export"
96128 "extends"
97− "const"
129+ "set"
130+ "get"
98131] @keyword
132+
runtime/queries/gdscript/indents.scm+1−1
@@ -12,6 +12,7 @@
1212
1313 (dictionary (_))
1414 (array (_))
15+ (setget)
1516] @indent
1617
1718[
@@ -25,7 +26,6 @@
2526 (class_definition)
2627] @extend
2728
28−
2929[
3030 (return_statement)
3131 (break_statement)
runtime/queries/godot-resource/injections.scm+16
@@ -1,2 +1,18 @@
11((comment) @injection.content
22 (#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+)