summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmaan Qureshi <amaanq12@gmail.com>2023-10-22 00:37:11 -0400
committerAmaan Qureshi <amaanq12@gmail.com>2023-10-22 01:17:15 -0400
commit6cb93819c9d7107f5e1ff704eb35d230858ec698 (patch)
tree07d16bba7fa76b2342e188a49570376686b87e7c
parentUpdate README (#5558) (diff)
downloadnvim-treesitter-6cb93819c9d7107f5e1ff704eb35d230858ec698.tar
nvim-treesitter-6cb93819c9d7107f5e1ff704eb35d230858ec698.tar.gz
nvim-treesitter-6cb93819c9d7107f5e1ff704eb35d230858ec698.tar.bz2
nvim-treesitter-6cb93819c9d7107f5e1ff704eb35d230858ec698.tar.lz
nvim-treesitter-6cb93819c9d7107f5e1ff704eb35d230858ec698.tar.xz
nvim-treesitter-6cb93819c9d7107f5e1ff704eb35d230858ec698.tar.zst
nvim-treesitter-6cb93819c9d7107f5e1ff704eb35d230858ec698.zip
feat: add GN (Generate Ninja)
-rw-r--r--README.md1
-rw-r--r--lockfile.json3
-rw-r--r--lua/nvim-treesitter/parsers.lua9
-rw-r--r--queries/gn/folds.scm6
-rw-r--r--queries/gn/highlights.scm74
-rw-r--r--queries/gn/indents.scm12
-rw-r--r--queries/gn/injections.scm2
-rw-r--r--queries/gn/locals.scm6
8 files changed, 113 insertions, 0 deletions
diff --git a/README.md b/README.md
index ad3182ca9..70a269b61 100644
--- a/README.md
+++ b/README.md
@@ -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)
diff --git a/lockfile.json b/lockfile.json
index 22a59021a..58dafe11e 100644
--- a/lockfile.json
+++ b/lockfile.json
@@ -200,6 +200,9 @@
"glsl": {
"revision": "952739a25a7c014882aa777f1a32da8950f31f58"
},
+ "gn": {
+ "revision": "492878ebee3552ac4631b064e02d19a00b894535"
+ },
"go": {
"revision": "bbaa67a180cfe0c943e50c55130918be8efb20bd"
},
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index 47a1593e1..82f3fd775 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -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",
diff --git a/queries/gn/folds.scm b/queries/gn/folds.scm
new file mode 100644
index 000000000..352b0f0ec
--- /dev/null
+++ b/queries/gn/folds.scm
@@ -0,0 +1,6 @@
+[
+ (list)
+ (block)
+ (if_statement)
+ (else_statement)
+] @fold
diff --git a/queries/gn/highlights.scm b/queries/gn/highlights.scm
new file mode 100644
index 000000000..87082a30a
--- /dev/null
+++ b/queries/gn/highlights.scm
@@ -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
diff --git a/queries/gn/indents.scm b/queries/gn/indents.scm
new file mode 100644
index 000000000..82f44711d
--- /dev/null
+++ b/queries/gn/indents.scm
@@ -0,0 +1,12 @@
+[
+ (block)
+ (parenthesized_expression)
+] @indent.begin
+
+[
+ "}"
+ ")"
+ "]"
+] @indent.end @indent.branch
+
+(comment) @indent.auto
diff --git a/queries/gn/injections.scm b/queries/gn/injections.scm
new file mode 100644
index 000000000..2f0e58eb6
--- /dev/null
+++ b/queries/gn/injections.scm
@@ -0,0 +1,2 @@
+((comment) @injection.content
+ (#set! injection.language "comment"))
diff --git a/queries/gn/locals.scm b/queries/gn/locals.scm
new file mode 100644
index 000000000..1350a2318
--- /dev/null
+++ b/queries/gn/locals.scm
@@ -0,0 +1,6 @@
+[
+ (source_file)
+ (block)
+] @scope
+
+(identifier) @reference