summaryrefslogtreecommitdiff
path: root/queries
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 /queries
parentc090007a881f4cba6b98f5cff407855ed8d8dea9 (diff)
Add ninja parser (#2217)
* Add ninja parser * Add branch main * No need for ftdetect
Diffstat (limited to 'queries')
-rw-r--r--queries/ninja/folds.scm1
-rw-r--r--queries/ninja/highlights.scm98
-rw-r--r--queries/ninja/indents.scm6
3 files changed, 105 insertions, 0 deletions
diff --git a/queries/ninja/folds.scm b/queries/ninja/folds.scm
new file mode 100644
index 00000000..341a8b8c
--- /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 00000000..1b31b560
--- /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 00000000..088dec2c
--- /dev/null
+++ b/queries/ninja/indents.scm
@@ -0,0 +1,6 @@
+[
+ (pool)
+ (rule)
+ (build)
+] @indent
+