Skip to content

Commit

Permalink
WIP nix
Browse files Browse the repository at this point in the history
  • Loading branch information
domenkozar committed Oct 17, 2024
1 parent 7b1c316 commit b68d88e
Show file tree
Hide file tree
Showing 7 changed files with 350 additions and 36 deletions.
56 changes: 32 additions & 24 deletions topiary-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ name = "topiary-cli"
description = "CLI app for Topiary, the universal code formatter."
categories = ["command-line-utilities", "development-tools", "text-processing"]
keywords = [
"cli",
"code-formatter",
"formatter",
"text",
"tree-sitter",
"utility",
"cli",
"code-formatter",
"formatter",
"text",
"tree-sitter",
"utility",
]
version.workspace = true
edition.workspace = true
Expand All @@ -35,7 +35,12 @@ itertools = { workspace = true }
log = { workspace = true }
serde = { workspace = true, features = ["derive"] }
tempfile = { workspace = true }
tokio = { workspace = true, features = ["fs", "rt-multi-thread", "sync", "macros"] }
tokio = { workspace = true, features = [
"fs",
"rt-multi-thread",
"sync",
"macros",
] }
toml = { workspace = true }
topiary-core = { path = "../topiary-core" }
topiary-config = { path = "../topiary-config" }
Expand All @@ -58,34 +63,37 @@ predicates = { workspace = true }

[features]
default = [
"contributed",
"json",
"nickel",
"ocaml",
"ocaml_interface",
"ocamllex",
"toml",
"tree_sitter_query"
"contributed",
"json",
"nickel",
"nix",
"ocaml",
"ocaml_interface",
"ocamllex",
"toml",
"tree_sitter_query",
]

# Included by default
contributed = [
"css"
]
contributed = ["css"]

# Excluded by default
experimental = [
"bash",
"rust",
]
experimental = ["bash", "rust"]

nix = ["topiary-config/nix", "topiary-queries/nix"]
bash = ["topiary-config/bash", "topiary-queries/bash"]
css = ["topiary-config/css", "topiary-queries/css"]
json = ["topiary-config/json", "topiary-queries/json"]
nickel = ["topiary-config/nickel", "topiary-queries/nickel"]
ocaml = ["topiary-config/ocaml", "topiary-queries/ocaml"]
ocaml_interface = ["topiary-config/ocaml_interface", "topiary-queries/ocaml_interface"]
ocaml_interface = [
"topiary-config/ocaml_interface",
"topiary-queries/ocaml_interface",
]
ocamllex = ["topiary-config/ocamllex", "topiary-queries/ocamllex"]
rust = ["topiary-config/rust", "topiary-queries/rust"]
toml = ["topiary-config/toml", "topiary-queries/toml"]
tree_sitter_query = ["topiary-config/tree_sitter_query", "topiary-queries/tree_sitter_query"]
tree_sitter_query = [
"topiary-config/tree_sitter_query",
"topiary-queries/tree_sitter_query",
]
3 changes: 3 additions & 0 deletions topiary-cli/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@ where
#[cfg(feature = "toml")]
"toml" => Ok(topiary_queries::toml().into()),

#[cfg(feature = "nix")]
"nix" => Ok(topiary_queries::nix().into()),

#[cfg(feature = "tree_sitter_query")]
"tree_sitter_query" => Ok(topiary_queries::tree_sitter_query().into()),

Expand Down
26 changes: 14 additions & 12 deletions topiary-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ git2.workspace = true
libloading.workspace = true

[features]
default = [ "parallel" ]
default = ["parallel"]

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

bash = []
css = []
Expand All @@ -46,21 +46,23 @@ nickel = []
ocaml = []
ocaml_interface = []
ocamllex = []
nix = []
rust = []
toml = []
tree_sitter_query = []

# This a convenience for the sake of downstream applications which don't
# wish to cherry-pick grammars (e.g., the playground)
all = [
"bash",
"css",
"json",
"nickel",
"ocaml",
"ocaml_interface",
"ocamllex",
"rust",
"toml",
"tree_sitter_query"
"bash",
"css",
"json",
"nickel",
"ocaml",
"ocaml_interface",
"ocamllex",
"rust",
"nix",
"toml",
"tree_sitter_query",
]
8 changes: 8 additions & 0 deletions topiary-config/languages.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
},
},

nix = {
extensions = ["nix"],
grammar = {
git = https://github.com/nix-community/tree-sitter-nix""
rev = "456b14a2fa6315abc7e02fcffaf4a1f35d4955d3",
},
},

json = {
extensions = [
"json",
Expand Down
1 change: 1 addition & 0 deletions topiary-queries/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ ocaml_interface = []
ocamllex = []
rust = []
toml = []
nix = []
tree_sitter_query = []
Loading

0 comments on commit b68d88e

Please sign in to comment.