diff options
| author | Dax Raad <[email protected]> | 2026-01-04 13:04:28 -0500 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2026-01-04 13:04:28 -0500 |
| commit | cdd6ea514b94d8ce71770bb02f33ab979e9ee0f6 (patch) | |
| tree | 576b5fb22d551381cb38f1f8ff99ea5cab95d778 | |
| parent | 24d9c1d18d63650c42b8ccef7a9427b946c2b268 (diff) | |
| download | opencode-cdd6ea514b94d8ce71770bb02f33ab979e9ee0f6.tar.gz opencode-cdd6ea514b94d8ce71770bb02f33ab979e9ee0f6.zip | |
core: improve Rust formatter detection and add cargo fmt support
| -rw-r--r-- | packages/opencode/src/format/formatter.ts | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/packages/opencode/src/format/formatter.ts b/packages/opencode/src/format/formatter.ts index cf68944a3..668a2049d 100644 --- a/packages/opencode/src/format/formatter.ts +++ b/packages/opencode/src/format/formatter.ts @@ -337,6 +337,23 @@ export const rustfmt: Info = { command: ["rustfmt", "$FILE"], extensions: [".rs"], async enabled() { - return Bun.which("rustfmt") !== null + if (!Bun.which("rustfmt")) return false + const configs = ["rustfmt.toml", ".rustfmt.toml"] + for (const config of configs) { + const found = await Filesystem.findUp(config, Instance.directory, Instance.worktree) + if (found.length > 0) return true + } + return false + }, +} + +export const cargofmt: Info = { + name: "cargo fmt", + command: ["cargo", "fmt", "--", "$FILE"], + extensions: [".rs"], + async enabled() { + if (!Bun.which("cargo")) return false + const found = await Filesystem.findUp("Cargo.toml", Instance.directory, Instance.worktree) + return found.length > 0 }, } |
