From f6a050c8d08ca0f5e1a8b4cbda4387307338ed76 Mon Sep 17 00:00:00 2001 From: Farhad Omid Date: Tue, 30 Dec 2025 23:26:54 +0100 Subject: [PATCH 1/2] feat(format): add rustfmt formatter for Rust files Add support for automatic formatting of Rust files (.rs) using rustfmt. The formatter is auto-enabled when rustfmt is available in PATH. --- packages/opencode/src/format/formatter.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/opencode/src/format/formatter.ts b/packages/opencode/src/format/formatter.ts index 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 + }, +} From f656bda0bdd5912f43e52af78640390d0767d24a Mon Sep 17 00:00:00 2001 From: Farhad Omid Date: Tue, 30 Dec 2025 23:43:37 +0100 Subject: [PATCH 2/2] docs: add rustfmt to formatters documentation --- packages/web/src/content/docs/formatters.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/web/src/content/docs/formatters.mdx b/packages/web/src/content/docs/formatters.mdx index 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 |