Skip to content

Commit b68d88e

Browse files
committed
WIP nix
1 parent 7b1c316 commit b68d88e

File tree

7 files changed

+350
-36
lines changed

7 files changed

+350
-36
lines changed

topiary-cli/Cargo.toml

+32-24
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ name = "topiary-cli"
33
description = "CLI app for Topiary, the universal code formatter."
44
categories = ["command-line-utilities", "development-tools", "text-processing"]
55
keywords = [
6-
"cli",
7-
"code-formatter",
8-
"formatter",
9-
"text",
10-
"tree-sitter",
11-
"utility",
6+
"cli",
7+
"code-formatter",
8+
"formatter",
9+
"text",
10+
"tree-sitter",
11+
"utility",
1212
]
1313
version.workspace = true
1414
edition.workspace = true
@@ -35,7 +35,12 @@ itertools = { workspace = true }
3535
log = { workspace = true }
3636
serde = { workspace = true, features = ["derive"] }
3737
tempfile = { workspace = true }
38-
tokio = { workspace = true, features = ["fs", "rt-multi-thread", "sync", "macros"] }
38+
tokio = { workspace = true, features = [
39+
"fs",
40+
"rt-multi-thread",
41+
"sync",
42+
"macros",
43+
] }
3944
toml = { workspace = true }
4045
topiary-core = { path = "../topiary-core" }
4146
topiary-config = { path = "../topiary-config" }
@@ -58,34 +63,37 @@ predicates = { workspace = true }
5863

5964
[features]
6065
default = [
61-
"contributed",
62-
"json",
63-
"nickel",
64-
"ocaml",
65-
"ocaml_interface",
66-
"ocamllex",
67-
"toml",
68-
"tree_sitter_query"
66+
"contributed",
67+
"json",
68+
"nickel",
69+
"nix",
70+
"ocaml",
71+
"ocaml_interface",
72+
"ocamllex",
73+
"toml",
74+
"tree_sitter_query",
6975
]
7076

7177
# Included by default
72-
contributed = [
73-
"css"
74-
]
78+
contributed = ["css"]
7579

7680
# Excluded by default
77-
experimental = [
78-
"bash",
79-
"rust",
80-
]
81+
experimental = ["bash", "rust"]
8182

83+
nix = ["topiary-config/nix", "topiary-queries/nix"]
8284
bash = ["topiary-config/bash", "topiary-queries/bash"]
8385
css = ["topiary-config/css", "topiary-queries/css"]
8486
json = ["topiary-config/json", "topiary-queries/json"]
8587
nickel = ["topiary-config/nickel", "topiary-queries/nickel"]
8688
ocaml = ["topiary-config/ocaml", "topiary-queries/ocaml"]
87-
ocaml_interface = ["topiary-config/ocaml_interface", "topiary-queries/ocaml_interface"]
89+
ocaml_interface = [
90+
"topiary-config/ocaml_interface",
91+
"topiary-queries/ocaml_interface",
92+
]
8893
ocamllex = ["topiary-config/ocamllex", "topiary-queries/ocamllex"]
8994
rust = ["topiary-config/rust", "topiary-queries/rust"]
9095
toml = ["topiary-config/toml", "topiary-queries/toml"]
91-
tree_sitter_query = ["topiary-config/tree_sitter_query", "topiary-queries/tree_sitter_query"]
96+
tree_sitter_query = [
97+
"topiary-config/tree_sitter_query",
98+
"topiary-queries/tree_sitter_query",
99+
]

topiary-cli/src/io.rs

+3
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,9 @@ where
350350
#[cfg(feature = "toml")]
351351
"toml" => Ok(topiary_queries::toml().into()),
352352

353+
#[cfg(feature = "nix")]
354+
"nix" => Ok(topiary_queries::nix().into()),
355+
353356
#[cfg(feature = "tree_sitter_query")]
354357
"tree_sitter_query" => Ok(topiary_queries::tree_sitter_query().into()),
355358

topiary-config/Cargo.toml

+14-12
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ git2.workspace = true
3333
libloading.workspace = true
3434

3535
[features]
36-
default = [ "parallel" ]
36+
default = ["parallel"]
3737

3838
# Enabling the `parallel` feature enables parallel computation where possible.
3939
# At the moment, this is only in grammar prefetching
40-
parallel = [ "dep:rayon" ]
40+
parallel = ["dep:rayon"]
4141

4242
bash = []
4343
css = []
@@ -46,21 +46,23 @@ nickel = []
4646
ocaml = []
4747
ocaml_interface = []
4848
ocamllex = []
49+
nix = []
4950
rust = []
5051
toml = []
5152
tree_sitter_query = []
5253

5354
# This a convenience for the sake of downstream applications which don't
5455
# wish to cherry-pick grammars (e.g., the playground)
5556
all = [
56-
"bash",
57-
"css",
58-
"json",
59-
"nickel",
60-
"ocaml",
61-
"ocaml_interface",
62-
"ocamllex",
63-
"rust",
64-
"toml",
65-
"tree_sitter_query"
57+
"bash",
58+
"css",
59+
"json",
60+
"nickel",
61+
"ocaml",
62+
"ocaml_interface",
63+
"ocamllex",
64+
"rust",
65+
"nix",
66+
"toml",
67+
"tree_sitter_query",
6668
]

topiary-config/languages.ncl

+8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616
},
1717
},
1818

19+
nix = {
20+
extensions = ["nix"],
21+
grammar = {
22+
git = https://github.com/nix-community/tree-sitter-nix""
23+
rev = "456b14a2fa6315abc7e02fcffaf4a1f35d4955d3",
24+
},
25+
},
26+
1927
json = {
2028
extensions = [
2129
"json",

topiary-queries/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ ocaml_interface = []
2424
ocamllex = []
2525
rust = []
2626
toml = []
27+
nix = []
2728
tree_sitter_query = []

0 commit comments

Comments
 (0)