Add ninja parser (#2217)

* Add ninja parser

* Add branch main

* No need for ftdetect
This commit is contained in:
Alexandre A. Muller 2022-01-08 01:26:33 +00:00 committed by GitHub
parent c090007a88
commit a7c0c1764b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 115 additions and 0 deletions

1
queries/ninja/folds.scm Normal file
View file

@ -0,0 +1 @@
(body) @fold

View file

@ -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

View file

@ -0,0 +1,6 @@
[
(pool)
(rule)
(build)
] @indent