Skip to content

Commit cf86370

Browse files
authored
feat: Add Ninja support (#299)
1 parent 79eabcf commit cf86370

File tree

5 files changed

+107
-0
lines changed

5 files changed

+107
-0
lines changed

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,3 +564,9 @@
564564
update = none
565565
ignore = dirty
566566
branch = main
567+
[submodule "repos/ninja"]
568+
path = repos/ninja
569+
url = https://github.com/alemuller/tree-sitter-ninja
570+
update = none
571+
ignore = dirty
572+
branch = main

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Changelog
22

33
## Unreleased
4+
- Add `Ninja` support
45

56
## 0.12.88 - 2023-12-21
67

queries/ninja/highlights.scm

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
[
2+
"default"
3+
"pool"
4+
"rule"
5+
"build"
6+
] @keyword
7+
8+
[
9+
"include"
10+
"subninja"
11+
] @include
12+
13+
[
14+
":"
15+
] @punctuation.delimiter
16+
17+
[
18+
"="
19+
"|"
20+
"||"
21+
"|@"
22+
] @operator
23+
24+
[
25+
"$"
26+
"{"
27+
"}"
28+
] @punctuation.special
29+
30+
;;
31+
;; Names
32+
;; =====
33+
(pool name: (identifier) @type)
34+
(rule name: (identifier) @function)
35+
(let name: (identifier) @constant)
36+
(expansion (identifier) @constant)
37+
(build rule: (identifier) @function)
38+
39+
;;
40+
;; Paths and Text
41+
;; ==============
42+
(path) @string.special
43+
(text) @string
44+
45+
;;
46+
;; Builtins
47+
;; ========
48+
(pool name: (identifier) @type.builtin
49+
(#any-of? @type.builtin "console"))
50+
(build rule: (identifier) @function.builtin
51+
(#any-of? @function.builtin "phony" "dyndep"))
52+
53+
;; Top level bindings
54+
;; ------------------
55+
(manifest
56+
(let name: ((identifier) @constant.builtin
57+
(#any-of? @constant.builtin "builddir"
58+
"ninja_required_version"))))
59+
60+
;; Rules bindings
61+
;; -----------------
62+
(rule
63+
(body
64+
(let name: (identifier) @constant.builtin
65+
(#not-any-of? @constant.builtin "command"
66+
"depfile"
67+
"deps"
68+
"msvc_deps_prefix"
69+
"description"
70+
"dyndep"
71+
"generator"
72+
"in"
73+
"in_newline"
74+
"out"
75+
"restat"
76+
"rspfile"
77+
"rspfile_content"
78+
"pool"))))
79+
80+
;;
81+
;; Expansion
82+
;; ---------
83+
(expansion
84+
(identifier) @constant.macro
85+
(#any-of? @constant.macro "in" "out"))
86+
87+
;;
88+
;; Escape sequences
89+
;; ================
90+
(quote) @string.escape
91+
92+
;;
93+
;; Others
94+
;; ======
95+
[
96+
(split)
97+
(comment)
98+
] @comment

repos/ninja

Submodule ninja added at 0a95cfd

tree-sitter-langs.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ See `tree-sitter-langs-repos'."
177177
(matlab-mode . matlab)
178178
(mermaid-mode . mermaid)
179179
(meson-mode . meson)
180+
(ninja-mode . ninja)
180181
(noir-mode . noir)
181182
(ocaml-mode . ocaml)
182183
(org-mode . org)

0 commit comments

Comments
 (0)