The open source coding agent.
TypeScript
feat(format): add rustfmt formatter for Rust files (#6482)
Farhad Omid76c25ef286b5
diff --git a/packages/opencode/src/format/formatter.ts b/packages/opencode/src/format/formatter.tsindex dedc50fee34..cf68944a330 100644--- a/packages/opencode/src/format/formatter.ts+++ b/packages/opencode/src/format/formatter.ts@@ -331,3 +331,12 @@ export const nixfmt: Info = {return Bun.which("nixfmt") !== null},}++export const rustfmt: Info = {+ name: "rustfmt",+ command: ["rustfmt", "$FILE"],+ extensions: [".rs"],+ async enabled() {+ return Bun.which("rustfmt") !== null+ },+}diff --git a/packages/web/src/content/docs/formatters.mdx b/packages/web/src/content/docs/formatters.mdxindex 137d3be1ee1..b49ec71c307 100644--- a/packages/web/src/content/docs/formatters.mdx+++ b/packages/web/src/content/docs/formatters.mdx@@ -21,6 +21,7 @@ OpenCode comes with several built-in formatters for popular languages and framew| clang-format | .c, .cpp, .h, .hpp, .ino, and [more](https://clang.llvm.org/docs/ClangFormat.html) | `.clang-format` config file || ktlint | .kt, .kts | `ktlint` command available || ruff | .py, .pyi | `ruff` command available with config |+| rustfmt | .rs | `rustfmt` command available || uv | .py, .pyi | `uv` command available || rubocop | .rb, .rake, .gemspec, .ru | `rubocop` command available || standardrb | .rb, .rake, .gemspec, .ru | `standardrb` command available |