Skip to content

Commit bfbcbc8

Browse files
authored
feat(formatters): add laravel pint as a .php formatter (anomalyco#7312)
1 parent fd77d31 commit bfbcbc8

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

packages/opencode/src/format/formatter.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,3 +340,18 @@ export const rustfmt: Info = {
340340
return Bun.which("rustfmt") !== null
341341
},
342342
}
343+
344+
export const pint: Info = {
345+
name: "pint",
346+
command: ["./vendor/bin/pint", "$FILE"],
347+
extensions: [".php"],
348+
async enabled() {
349+
const items = await Filesystem.findUp("composer.json", Instance.directory, Instance.worktree)
350+
for (const item of items) {
351+
const json = await Bun.file(item).json()
352+
if (json.require?.["laravel/pint"]) return true
353+
if (json["require-dev"]?.["laravel/pint"]) return true
354+
}
355+
return false
356+
},
357+
}

packages/web/src/content/docs/formatters.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ OpenCode comes with several built-in formatters for popular languages and framew
3434
| gleam | .gleam | `gleam` command available |
3535
| nixfmt | .nix | `nixfmt` command available |
3636
| shfmt | .sh, .bash | `shfmt` command available |
37+
| pint | .php | `laravel/pint` dependency in `composer.json` |
3738
| oxfmt (Experimental) | .js, .jsx, .ts, .tsx | `oxfmt` dependency in `package.json` and an [experimental env variable flag](/docs/cli/#experimental) |
3839

3940
So if your project has `prettier` in your `package.json`, OpenCode will automatically use it.

0 commit comments

Comments
 (0)