Jelajahi Sumber

add zig, python, clang, and kotlin formatters

Co-authored-by: Suhas-Koheda <[email protected]>
Co-authored-by: Polo123456789 <[email protected]>
Co-authored-by: theodore-s-beers <[email protected]>
Co-authored-by: TylerHillery <[email protected]>
Dax Raad 7 bulan lalu
induk
melakukan
463257e7e4
1 mengubah file dengan 50 tambahan dan 0 penghapusan
  1. 50 0
      packages/opencode/src/format/formatters.ts

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