Skip to content

Commit

Permalink
Update grammar for godot.
Browse files Browse the repository at this point in the history
* update grammar for gdscript.
* add comment injections for gdscript.
* add indent for gdscript
* add file-type support for godot-resource
  • Loading branch information
erasin committed Feb 12, 2023
1 parent a4751db commit 05f4b55
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 4 deletions.
6 changes: 3 additions & 3 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1449,13 +1449,13 @@ indent = { tab-width = 4, unit = "\t" }

[[grammar]]
name = "gdscript"
source = { git = "https://github.com/PrestonKnopp/tree-sitter-gdscript", rev = "2a6abdaa47fcb91397e09a97c7433fd995ea46c6" }

source = { git = "https://github.com/PrestonKnopp/tree-sitter-gdscript", rev = "a56a6fcec3fb63ec3324bf9373aae7298861eb30" }
[[language]]
name = "godot-resource"
scope = "source.tscn"
injection-regex = "godot"
file-types = ["tscn","tres"]
file-types = ["tscn", "tres", "godot", "gdextension"]
shebangs = []
roots = ["project.godot"]
auto-format = false
Expand Down
38 changes: 38 additions & 0 deletions runtime/queries/gdscript/indents.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[
(if_statement)
(for_statement)
(while_statement)
(match_statement)
(pattern_section)

(function_definition)
(constructor_definition)
(class_definition)
(enum_definition)

; (setget)
(dictionary (_))
(array (_))
] @indent

[
(if_statement)
(for_statement)
(while_statement)
(match_statement)
(pattern_section)

(function_definition)
(class_definition)

(setget)
] @extend


[
(return_statement)
(break_statement)
(continue_statement)
(pass_statement)
] @extend.prevent-once

2 changes: 2 additions & 0 deletions runtime/queries/gdscript/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
((comment) @injection.content
(#set! injection.language "comment"))
3 changes: 2 additions & 1 deletion runtime/queries/godot-resource/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@

"=" @operator

(ERROR) @error
(ERROR) @error
(comment) @comment
2 changes: 2 additions & 0 deletions runtime/queries/godot-resource/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
((comment) @injection.content
(#set! injection.language "comment"))

0 comments on commit 05f4b55

Please sign in to comment.