aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre A. Muller <muller@outlook.com>2022-01-08 01:26:33 +0000
committerGitHub <noreply@github.com>2022-01-08 01:26:33 +0000
commita7c0c1764b0b583d0597108dd7d48bc5c0f98c81 (patch)
tree906ce9072e941297d86b307f35a7ae85fc9eda2e
parenthighlights(make): add all special targets (diff)
downloadnvim-treesitter-a7c0c1764b0b583d0597108dd7d48bc5c0f98c81.tar
nvim-treesitter-a7c0c1764b0b583d0597108dd7d48bc5c0f98c81.tar.gz
nvim-treesitter-a7c0c1764b0b583d0597108dd7d48bc5c0f98c81.tar.bz2
nvim-treesitter-a7c0c1764b0b583d0597108dd7d48bc5c0f98c81.tar.lz
nvim-treesitter-a7c0c1764b0b583d0597108dd7d48bc5c0f98c81.tar.xz
nvim-treesitter-a7c0c1764b0b583d0597108dd7d48bc5c0f98c81.tar.zst
nvim-treesitter-a7c0c1764b0b583d0597108dd7d48bc5c0f98c81.zip
Add ninja parser (#2217)
* Add ninja parser * Add branch main * No need for ftdetect
-rw-r--r--README.md1
-rw-r--r--lua/nvim-treesitter/parsers.lua9
-rw-r--r--queries/ninja/folds.scm1
-rw-r--r--queries/ninja/highlights.scm98
-rw-r--r--queries/ninja/indents.scm6
5 files changed, 115 insertions, 0 deletions
diff --git a/README.md b/README.md
index a524a30d9..ddc42caea 100644
--- a/README.md
+++ b/README.md
@@ -208,6 +208,7 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [lua](https://github.com/nvim-treesitter/tree-sitter-lua) (maintained by @vigoux)
- [x] [make](https://github.com/alemuller/tree-sitter-make) (maintained by @lewis6991)
- [ ] [markdown](https://github.com/MDeiml/tree-sitter-markdown)
+- [x] [ninja](https://github.com/alemuller/tree-sitter-ninja) (maintained by @alemuller)
- [x] [nix](https://github.com/cstrahan/tree-sitter-nix) (maintained by @leo60228)
- [x] [ocaml](https://github.com/tree-sitter/tree-sitter-ocaml) (maintained by @undu)
- [x] [ocaml_interface](https://github.com/tree-sitter/tree-sitter-ocaml) (maintained by @undu)
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index 9299874f2..d71655f6c 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -532,6 +532,15 @@ list.yang = {
filetype = "yang",
}
+list.ninja = {
+ install_info = {
+ url = "https://github.com/alemuller/tree-sitter-ninja",
+ files = { "src/parser.c" },
+ branch = "main",
+ },
+ maintainers = { "@alemuller" },
+}
+
list.nix = {
install_info = {
url = "https://github.com/cstrahan/tree-sitter-nix",
diff --git a/queries/ninja/folds.scm b/queries/ninja/folds.scm
new file mode 100644
index 000000000..341a8b8c1
--- /dev/null
+++ b/queries/ninja/folds.scm
@@ -0,0 +1 @@
+(body) @fold
diff --git a/queries/ninja/highlights.scm b/queries/ninja/highlights.scm
new file mode 100644
index 000000000..1b31b560c
--- /dev/null
+++ b/queries/ninja/highlights.scm
@@ -0,0 +1,98 @@
+[
+ "default"
+ "pool"
+ "rule"
+ "build"
+] @keyword
+
+[
+ "include"
+ "subninja"
+] @include
+
+[
+ ":"
+] @punctuation.delimiter
+
+[
+ "="
+ "|"
+ "||"
+ "|@"
+] @operator
+
+[
+ "$"
+ "{"
+ "}"
+] @punctuation.special
+
+;;
+;; Names
+;; =====
+(pool name: (identifier) @type)
+(rule name: (identifier) @function)
+(let name: (identifier) @constant)
+(expansion (identifier) @constant)
+(build rule: (identifier) @function)
+
+;;
+;; Paths and Text
+;; ==============
+(path) @string.special
+(text) @string
+
+;;
+;; Builtins
+;; ========
+(pool name: (identifier) @type.builtin
+ (#any-of? @type.builtin "console"))
+(build rule: (identifier) @function.builtin
+ (#any-of? @function.builtin "phony" "dyndep"))
+
+;; Top level bindings
+;; ------------------
+(manifest
+ (let name: ((identifier) @constant.builtin
+ (#any-of? @constant.builtin "builddir"
+ "ninja_required_version"))))
+
+;; Rules bindings
+;; -----------------
+(rule
+ (body
+ (let name: (identifier) @constant.builtin
+ (#not-any-of? @constant.builtin "command"
+ "depfile"
+ "deps"
+ "msvc_deps_prefix"
+ "description"
+ "dyndep"
+ "generator"
+ "in"
+ "in_newline"
+ "out"
+ "restat"
+ "rspfile"
+ "rspfile_content"
+ "pool"))))
+
+;;
+;; Expansion
+;; ---------
+(expansion
+ (identifier) @constant.macro
+ (#any-of? @constant.macro "in" "out"))
+
+;;
+;; Escape sequences
+;; ================
+(quote) @string.escape
+
+;;
+;; Others
+;; ======
+[
+ (split)
+ (comment)
+] @comment
diff --git a/queries/ninja/indents.scm b/queries/ninja/indents.scm
new file mode 100644
index 000000000..088dec2cd
--- /dev/null
+++ b/queries/ninja/indents.scm
@@ -0,0 +1,6 @@
+[
+ (pool)
+ (rule)
+ (build)
+] @indent
+