feat: add GN (Generate Ninja)

This commit is contained in:
Amaan Qureshi 2023-10-22 00:37:11 -04:00
parent 2f15204510
commit 6cb93819c9
8 changed files with 113 additions and 0 deletions

View file

@ -240,6 +240,7 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [gleam](https://github.com/gleam-lang/tree-sitter-gleam) (maintained by @amaanq)
- [x] [Glimmer and Ember](https://github.com/alexlafroscia/tree-sitter-glimmer) (maintained by @NullVoxPopuli)
- [x] [glsl](https://github.com/theHamsta/tree-sitter-glsl) (maintained by @theHamsta)
- [x] [GN (Generate Ninja)](https://github.com/amaanq/tree-sitter-gn) (maintained by @amaanq)
- [x] [go](https://github.com/tree-sitter/tree-sitter-go) (maintained by @theHamsta, @WinWisely268)
- [x] [Godot Resources (gdresource)](https://github.com/PrestonKnopp/tree-sitter-godot-resource) (maintained by @pierpo)
- [x] [gomod](https://github.com/camdencheek/tree-sitter-go-mod) (maintained by @camdencheek)

View file

@ -200,6 +200,9 @@
"glsl": {
"revision": "952739a25a7c014882aa777f1a32da8950f31f58"
},
"gn": {
"revision": "492878ebee3552ac4631b064e02d19a00b894535"
},
"go": {
"revision": "bbaa67a180cfe0c943e50c55130918be8efb20bd"
},

View file

@ -641,6 +641,15 @@ list.glsl = {
maintainers = { "@theHamsta" },
}
list.gn = {
install_info = {
url = "https://github.com/amaanq/tree-sitter-gn",
files = { "src/parser.c", "src/scanner.c" },
},
maintainers = { "@amaanq" },
readme_name = "GN (Generate Ninja)",
}
list.go = {
install_info = {
url = "https://github.com/tree-sitter/tree-sitter-go",

6
queries/gn/folds.scm Normal file
View file

@ -0,0 +1,6 @@
[
(list)
(block)
(if_statement)
(else_statement)
] @fold

74
queries/gn/highlights.scm Normal file
View file

@ -0,0 +1,74 @@
; Includes
"import" @include
; Conditionals
[
"if"
"else"
] @conditional
; Repeats
"foreach" @repeat
; Operators
[
"="
"+="
"-="
"!"
"+"
"-"
"<"
"<="
">"
">="
"=="
"!="
"&&"
"||"
] @operator
; Variables
(identifier) @variable
; Functions
(call_expression function: (identifier) @function.call)
; Fields
(scope_access field: (identifier) @field)
; Literals
(string) @string
(escape_sequence) @string.escape
(expansion) @none
(integer) @number
(hex) @string.special
(boolean) @boolean
; Punctuation
[ "{" "}" "[" "]" "(" ")" ] @punctuation.bracket
[
"."
","
] @punctuation.delimiter
(expansion ["$" "${" "}"] @punctuation.special)
; Comments
(comment) @comment

12
queries/gn/indents.scm Normal file
View file

@ -0,0 +1,12 @@
[
(block)
(parenthesized_expression)
] @indent.begin
[
"}"
")"
"]"
] @indent.end @indent.branch
(comment) @indent.auto

View file

@ -0,0 +1,2 @@
((comment) @injection.content
(#set! injection.language "comment"))

6
queries/gn/locals.scm Normal file
View file

@ -0,0 +1,6 @@
[
(source_file)
(block)
] @scope
(identifier) @reference