Просмотр исходного кода

feat(format): add rustfmt formatter for Rust files (#6482)

Farhad Omid 1 месяц назад
Родитель
Сommit
76c25ef286

+ 9 - 0
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
+  },
+}

+ 1 - 0
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                                                                        |