Skip to content
Open
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
27 changes: 27 additions & 0 deletions packages/opencode/src/format/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,3 +394,30 @@ export const dfmt: Info = {
return which("dfmt") !== null
},
}

export const stylua: Info = {
name: "stylua",
command: ["stylua", "$FILE"],
extensions: [".lua"],
async enabled() {
return which("stylua") !== null
},
}

export const nimpretty: Info = {
name: "nimpretty",
command: ["nimpretty", "-w", "$FILE"],
extensions: [".nim"],
async enabled() {
return which("nimpretty") !== null
},
}

export const elmformat: Info = {
name: "elm-format",
command: ["elm-format", "--yes", "$FILE"],
extensions: [".elm"],
async enabled() {
return which("elm-format") !== null
},
}
3 changes: 3 additions & 0 deletions packages/web/src/content/docs/formatters.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ OpenCode comes with several built-in formatters for popular languages and framew
| cljfmt | .clj, .cljs, .cljc, .edn | `cljfmt` command available |
| dart | .dart | `dart` command available |
| dfmt | .d | `dfmt` command available |
| elm-format | .elm | `elm-format` command available |
| gleam | .gleam | `gleam` command available |
| gofmt | .go | `gofmt` command available |
| htmlbeautifier | .erb, .html.erb | `htmlbeautifier` command available |
| ktlint | .kt, .kts | `ktlint` command available |
| mix | .ex, .exs, .eex, .heex, .leex, .neex, .sface | `mix` command available |
| nimpretty | .nim | `nimpretty` command available |
| nixfmt | .nix | `nixfmt` command available |
| ocamlformat | .ml, .mli | `ocamlformat` command available and `.ocamlformat` config file |
| ormolu | .hs | `ormolu` command available |
Expand All @@ -36,6 +38,7 @@ OpenCode comes with several built-in formatters for popular languages and framew
| rustfmt | .rs | `rustfmt` command available |
| shfmt | .sh, .bash | `shfmt` command available |
| standardrb | .rb, .rake, .gemspec, .ru | `standardrb` command available |
| stylua | .lua | `stylua` command available |
| terraform | .tf, .tfvars | `terraform` command available |
| uv | .py, .pyi | `uv` command available |
| zig | .zig, .zon | `zig` command available |
Expand Down
Loading