aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErasin Wang2023-03-05 18:41:18 +0000
committerGitHub2023-03-05 18:41:18 +0000
commite6597bc9927c73800d31d4a45dc695a4abe77ec8 (patch)
tree4e1d028d109a7f187777be36e439d0426054c6fd
parentdef26966d22dfc4b9a74e51542db246ba52f3dc9 (diff)
Update queries for godot4 (#6186)
-rw-r--r--languages.toml2
-rw-r--r--runtime/queries/gdscript/highlights.scm88
-rw-r--r--runtime/queries/gdscript/indents.scm2
-rw-r--r--runtime/queries/godot-resource/injections.scm16
4 files changed, 79 insertions, 29 deletions
diff --git a/languages.toml b/languages.toml
index e9a77b5a..c3413524 100644
--- a/languages.toml
+++ b/languages.toml
@@ -1463,7 +1463,7 @@ indent = { tab-width = 4, unit = "\t" }
[[grammar]]
name = "gdscript"
-source = { git = "https://github.com/PrestonKnopp/tree-sitter-gdscript", rev = "a56a6fcec3fb63ec3324bf9373aae7298861eb30" }
+source = { git = "https://github.com/PrestonKnopp/tree-sitter-gdscript", rev = "a4b57cc3bcbfc24550e858159647e9238e7ad1ac" }
[[language]]
name = "godot-resource"
diff --git a/runtime/queries/gdscript/highlights.scm b/runtime/queries/gdscript/highlights.scm
index f36f4e35..88f2a187 100644
--- a/runtime/queries/gdscript/highlights.scm
+++ b/runtime/queries/gdscript/highlights.scm
@@ -1,7 +1,8 @@
; Identifier naming conventions
-((identifier) @constant
- (#match? @constant "^[A-Z][A-Z_]*$"))
+(
+ (identifier) @constant
+ (#match? @constant "^[A-Z][A-Z\\d_]+$"))
; class
(class_name_statement (name) @type)
@@ -11,32 +12,35 @@
; Function calls
(attribute_call (identifier) @function)
-
(base_call (identifier) @function)
-
(call (identifier) @function)
; Function definitions
(function_definition (name) @function)
-
(constructor_definition "_init" @function)
+
;; Literals
-(integer) @constant.numeric.integer
-(float) @constant.numeric.float
(comment) @comment
(string) @string
-(escape_sequence) @constant.character.escape
-(identifier) @variable
+
(type) @type
+(expression_statement (array (identifier) @type))
+(binary_operator (identifier) @type)
-;; Literals
+(variable_statement (identifier) @variable)
+(get_node) @label
+
+(const_statement (name) @constant)
+(integer) @constant.numeric.integer
+(float) @constant.numeric.float
+(escape_sequence) @constant.character.escape
[
(true)
(false)
- (null)
-] @constant.builtin
+] @constant.builtin.boolean
+(null) @constant.builtin
[
"+"
@@ -62,37 +66,67 @@
"~"
"<<"
">>"
- "and"
- "or"
- "not"
] @operator
+(annotation (identifier) @keyword.storage.modifier)
+
[
- (static_keyword)
- (remote_keyword)
- (tool_statement)
- "var"
- "func"
- "setget"
- "in"
- "is"
- "as"
"if"
"else"
"elif"
+] @keyword.control.conditional
+
+[
"while"
"for"
+] @keyword.control.repeat
+
+[
"return"
+ "pass"
"break"
"continue"
- "pass"
+] @keyword.control.return
+
+[
+ "func"
+] @keyword.control.function
+
+[
+ "export"
+] @keyword.control.import
+
+[
+ "in"
+ "is"
+ "as"
"match"
+ "and"
+ "or"
+ "not"
+] @keyword.operator
+
+[
+ "var"
"class"
"class_name"
"enum"
+] @keyword.storage.type
+
+
+[
+ (remote_keyword)
+ (static_keyword)
+ "const"
"signal"
+ "@"
+] @keyword.storage.modifier
+
+[
+ "setget"
"onready"
- "export"
"extends"
- "const"
+ "set"
+ "get"
] @keyword
+
diff --git a/runtime/queries/gdscript/indents.scm b/runtime/queries/gdscript/indents.scm
index 1ab41a44..c969eb7c 100644
--- a/runtime/queries/gdscript/indents.scm
+++ b/runtime/queries/gdscript/indents.scm
@@ -12,6 +12,7 @@
(dictionary (_))
(array (_))
+ (setget)
] @indent
[
@@ -25,7 +26,6 @@
(class_definition)
] @extend
-
[
(return_statement)
(break_statement)
diff --git a/runtime/queries/godot-resource/injections.scm b/runtime/queries/godot-resource/injections.scm
index 321c90ad..7929d63c 100644
--- a/runtime/queries/godot-resource/injections.scm
+++ b/runtime/queries/godot-resource/injections.scm
@@ -1,2 +1,18 @@
((comment) @injection.content
(#set! injection.language "comment"))
+
+; ((section) @injection.content
+; (#set! injection.language "comment"))
+
+((section
+ (attribute
+ (identifier) @_type
+ (string) @_is_shader)
+ (property
+ (path) @_is_code
+ (string) @injection.content))
+ (#match? @_type "type")
+ (#match? @_is_shader "Shader")
+ (#eq? @_is_code "code")
+ (#set! injection.language "glsl")
+)