summaryrefslogtreecommitdiffhomepage
path: root/packages
diff options
context:
space:
mode:
authorFarhad Omid <[email protected]>2025-12-31 00:06:55 +0100
committerGitHub <[email protected]>2025-12-30 17:06:55 -0600
commit76c25ef286b5d52f4ba78216ea8b5757ad5ec8f5 (patch)
tree1cc7f14b9e3e6e1611553be4b0c7c3fd25b51023 /packages
parentc8b3b31d276baaa0e3f062a0102ad0ae5ffe6682 (diff)
downloadopencode-76c25ef286b5d52f4ba78216ea8b5757ad5ec8f5.tar.gz
opencode-76c25ef286b5d52f4ba78216ea8b5757ad5ec8f5.zip
feat(format): add rustfmt formatter for Rust files (#6482)
Diffstat (limited to 'packages')
-rw-r--r--packages/opencode/src/format/formatter.ts9
-rw-r--r--packages/web/src/content/docs/formatters.mdx1
2 files changed, 10 insertions, 0 deletions
diff --git a/packages/opencode/src/format/formatter.ts b/packages/opencode/src/format/formatter.ts
index dedc50fee..cf68944a3 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.mdx
index 137d3be1e..b49ec71c3 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 |