Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/opencode/src/format/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,12 @@ export const gleam: Info = {
return Bun.which("gleam") !== null
},
}

export const shfmt: Info = {
name: "shfmt",
command: ["shfmt", "-w", "$FILE"],
extensions: [".sh", ".bash"],
async enabled() {
return Bun.which("shfmt") !== null
},
}
1 change: 1 addition & 0 deletions packages/web/src/content/docs/formatters.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ OpenCode comes with several built-in formatters for popular languages and framew
| ocamlformat | .ml, .mli | `ocamlformat` command available and `.ocamlformat` config file |
| terraform | .tf, .tfvars | `terraform` command available |
| gleam | .gleam | `gleam` command available |
| shfmt | .sh, .bash | `shfmt` command available |
| 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.
Expand Down