From 463257e7e453ea17997247d3ffe18b981df1d7f2 Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Sun, 29 Jun 2025 21:25:32 -0400 Subject: [PATCH] add zig, python, clang, and kotlin formatters Co-authored-by: Suhas-Koheda Co-authored-by: Polo123456789 Co-authored-by: theodore-s-beers Co-authored-by: TylerHillery --- packages/opencode/src/format/formatters.ts | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/packages/opencode/src/format/formatters.ts b/packages/opencode/src/format/formatters.ts index ec4362b6..e1235282 100644 --- a/packages/opencode/src/format/formatters.ts +++ b/packages/opencode/src/format/formatters.ts @@ -74,3 +74,53 @@ export const prettier: Definition = { } }, } + +export const zig: Definition = { + name: "zig", + command: ["zig", "fmt", "$FILE"], + extensions: [".zig", ".zon"], + async enabled() { + return Bun.which("zig") !== null + }, +} + +export const clang: Definition = { + name: "clang-format", + command: ["clang-format", "-i", "$FILE"], + extensions: [ + ".c", + ".cc", + ".cpp", + ".cxx", + ".c++", + ".h", + ".hh", + ".hpp", + ".hxx", + ".h++", + ".ino", + ".C", + ".H", + ], + async enabled() { + return Bun.which("clang-format") !== null + }, +} + +export const ktlint: Definition = { + name: "ktlint", + command: ["ktlint", "-F", "$FILE"], + extensions: [".kt", ".kts"], + async enabled() { + return Bun.which("ktlint") !== null + }, +} + +export const ruff: Definition = { + name: "ruff", + command: ["ruff", "format", "$FILE"], + extensions: [".py", ".pyi"], + async enabled() { + return Bun.which("ruff") !== null + }, +}