Explorar el Código

feat(formatters): add laravel pint as a `.php` formatter (#7312)

nuno maduro hace 1 mes
padre
commit
bfbcbc8863

+ 15 - 0
packages/opencode/src/format/formatter.ts

@@ -340,3 +340,18 @@ export const rustfmt: Info = {
     return Bun.which("rustfmt") !== null
   },
 }
+
+export const pint: Info = {
+  name: "pint",
+  command: ["./vendor/bin/pint", "$FILE"],
+  extensions: [".php"],
+  async enabled() {
+    const items = await Filesystem.findUp("composer.json", Instance.directory, Instance.worktree)
+    for (const item of items) {
+      const json = await Bun.file(item).json()
+      if (json.require?.["laravel/pint"]) return true
+      if (json["require-dev"]?.["laravel/pint"]) return true
+    }
+    return false
+  },
+}

+ 1 - 0
packages/web/src/content/docs/formatters.mdx

@@ -34,6 +34,7 @@ OpenCode comes with several built-in formatters for popular languages and framew
 | gleam                | .gleam                                                                                                   | `gleam` command available                                                                             |
 | nixfmt               | .nix                                                                                                     | `nixfmt` command available                                                                            |
 | shfmt                | .sh, .bash                                                                                               | `shfmt` command available                                                                             |
+| pint                 | .php                                                                                                     | `laravel/pint` dependency in `composer.json`                                                          |
 | oxfmt (Experimental) | .js, .jsx, .ts, .tsx                                                                                     | `oxfmt` dependency in `package.json` and an [experimental env variable flag](/docs/cli/#experimental) |
 
 So if your project has `prettier` in your `package.json`, OpenCode will automatically use it.