Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ _Coming soon._
| YAML (incl. Kubernetes) | ✓ | ✓ | | ✓ | | |
| JSON | ✓ | ✓ | ✓ | | | |
| TOML | ✓ | ✓ | | ✓ | | |
| Nix | ✓ | ✓ | ✓ | ✓ | | |
| Solidity | ✓ | ✓ | ✓ | ✓ | ✓ | |
| Pascal | ✓ | ✓ | ✓ | ✓ | | |
| R | ✓ | ✓ | ✓ | ✓ | | |
Expand All @@ -187,7 +188,7 @@ Every listed language works with `aft_outline`, `aft_zoom`, and `read`/`edit`/`w

Objective-C `.h` headers continue to use the C grammar in v1, so Objective-C interfaces declared only in headers may outline imperfectly compared with `.m`/`.mm` implementation files.

Metal uses the C++ grammar because there is no maintained tree-sitter-metal grammar; covered shader qualifiers still produce ordinary function symbols. CUDA uses the dedicated tree-sitter-cuda grammar so kernel launches remain call expressions, and `__global__` definitions render as `kernel` symbols. TOML is structural for outline, zoom, and semantic chunking, but is intentionally absent from AST pattern tools because its key grammar does not accept ast-grep's identifier metavariable sentinels.
Metal uses the C++ grammar because there is no maintained tree-sitter-metal grammar; covered shader qualifiers still produce ordinary function symbols. CUDA uses the dedicated tree-sitter-cuda grammar so kernel launches remain call expressions, and `__global__` definitions render as `kernel` symbols. TOML is structural for outline, zoom, and semantic chunking, but is intentionally absent from AST pattern tools because its key grammar does not accept ast-grep's identifier metavariable sentinels. Nix supports outline, zoom, AST search/replace, and semantic chunking, but its Imports and Refactor columns are intentionally blank and it contributes no call-graph edges: bindings are not declarations; standalone bindings and `inherit` clauses use contextual patterns, while complete Nix expressions use the normal AST pattern path. `$NAME` metavariables are rewritten to `_NAME`, so an identifier of `_` followed by an all-uppercase name (`_FOO`) is read as a metavariable, while `_module.args`, `_Foo`, and `__functor` stay literal.

Indexes honor `.gitignore` and an optional `.aftignore` (same syntax) for paths git can't exclude, such as submodules. Naming a file explicitly in `grep` searches it even when ignored, matching ripgrep.

Expand Down
2 changes: 2 additions & 0 deletions assets/aft.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
"rustfmt",
"goimports",
"gofmt",
"nixfmt",
"none"
]
}
Expand Down Expand Up @@ -1004,6 +1005,7 @@
"rustfmt",
"goimports",
"gofmt",
"nixfmt",
"none"
]
}
Expand Down
6 changes: 4 additions & 2 deletions crates/aft-base/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -992,8 +992,10 @@ pub struct Config {
/// Optional automatic validation mode after edits (default: None, disabled).
/// When "syntax", only tree-sitter parse check. When "full", runs type checker.
pub validate_on_edit: Option<String>,
/// Per-language formatter overrides. Keys: "typescript", "python", "rust", "go".
/// Values: "biome", "oxfmt", "prettier", "deno", "ruff", "black", "rustfmt", "goimports", "gofmt", "none".
/// Per-language formatter overrides. Keys: "typescript", "python", "rust",
/// "go", "nix". Values: "biome", "oxfmt", "prettier", "deno", "ruff",
/// "black", "rustfmt", "goimports", "gofmt", "nixfmt", "none". Nix has no
/// auto-detection and formats only when "nix" is set explicitly.
pub formatter: HashMap<String, String>,
/// Per-language type checker overrides. Keys: "typescript", "python", "rust", "go".
/// Values: "tsc", "tsgo", "biome", "pyright", "ruff", "cargo", "go", "staticcheck", "none".
Expand Down
26 changes: 26 additions & 0 deletions crates/aft-base/src/config_resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ pub enum RawFormatter {
Rustfmt,
Goimports,
Gofmt,
Nixfmt,
Comment thread
kido5217 marked this conversation as resolved.
Resolved
None,
}

Expand All @@ -335,6 +336,7 @@ impl RawFormatter {
Self::Rustfmt => "rustfmt",
Self::Goimports => "goimports",
Self::Gofmt => "gofmt",
Self::Nixfmt => "nixfmt",
Self::None => "none",
}
}
Expand Down Expand Up @@ -4069,6 +4071,30 @@ where

#[cfg(test)]
mod tests {
#[test]
fn nixfmt_is_a_recognized_formatter_and_reaches_the_resolved_map() {
let raw = serde_json::from_str::<super::RawAftConfig>(r#"{"formatter":{"nix":"nixfmt"}}"#);
assert!(raw.is_ok(), "formatter.nix must accept nixfmt: {raw:?}");

let result = super::resolve_config_for_harness(
&[tier("user", r#"{"formatter":{"nix":"nixfmt"}}"#)],
Some(&Harness::Opencode),
);
assert!(result.errors.is_empty(), "{:?}", result.errors);
assert_eq!(
result.config.formatter.get("nix").map(String::as_str),
Some("nixfmt")
);
assert!(
!result
.dropped
.iter()
.any(|dropped| dropped.key.starts_with("formatter")),
"formatter.nix must not be dropped: {:?}",
result.dropped
);
}

#[test]
fn storage_cache_dir_is_a_recognized_user_setting() {
let raw = serde_json::from_str::<super::RawAftConfig>(
Expand Down
4 changes: 3 additions & 1 deletion crates/aft-base/src/lang_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub enum LangId {
ObjC,
Toml,
Luau,
Nix,
}

#[cfg(any(test, feature = "test-support"))]
Expand All @@ -50,7 +51,7 @@ pub const TEST_EXTENSIONS: &[&str] = &[
"htm", "md", "markdown", "mdx", "qmd", "Qmd", "rmd", "Rmd", "sol", "scss", "vue", "json",
"jsonc", "scala", "sc", "java", "rb", "kt", "kts", "swift", "inc", "php", "lua", "pl", "pm",
"t", "yaml", "yml", "pas", "pp", "dpr", "dpk", "lpr", "R", "r", "groovy", "gvy", "gy", "gsh",
"gradle", "m", "mm", "toml", "luau", "H", "unknown", "",
"gradle", "m", "mm", "toml", "luau", "nix", "H", "unknown", "",
];

/// Classify by name without reading the file. A `.h` result is provisional C;
Expand Down Expand Up @@ -98,6 +99,7 @@ pub fn native_language_by_extension(ext: &str) -> Option<LangId> {
"groovy" | "gvy" | "gy" | "gsh" | "gradle" => Some(LangId::Groovy),
"m" | "mm" => Some(LangId::ObjC),
"toml" => Some(LangId::Toml),
"nix" => Some(LangId::Nix),
_ => None,
}
}
1 change: 1 addition & 0 deletions crates/aft-parse/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ tree-sitter-solidity = "1.2"
tree-sitter-vue = { package = "tree-sitter-vue-next", version = "0.1" }
tree-sitter-json = "0.24"
tree-sitter-toml = { package = "tree-sitter-toml-ng", version = "0.7.0" }
tree-sitter-nix = "0.3.0"
tree-sitter-scala = "0.26"
tree-sitter-java = "0.23"
tree-sitter-ruby = "0.23"
Expand Down
Loading
Loading