Skip to content

Commit

Permalink
docs: document formatter configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
hougesen committed Mar 16, 2024
1 parent f7d46c1 commit b36f9ff
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 33 deletions.
72 changes: 43 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,39 +38,53 @@ If you are interested in customizing which formatter is run, you can create a ne
mdsf init
```

`mdsf` supports running multiple formatters on the save code snippet.

```json
{
// Only run `ruff` on Python snippets,
"python": "ruff",
// Run `usort` on file and then `black`
"python": ["usort", "black"],
// Run `usort`, if that fails run `isort`, finally run `black`
"python": [["usort", "isort"], "black"]
}
```

### Supported languages & formatters

> \[!NOTE\]
> mdsf is not a tool for installing formatters.
>
> Only formatters that are already installed will be used.
| Language | Formatters |
| ----------- | ----------------------------------------------- |
| C | `clang-format` |
| CSS | `prettier` |
| Cpp | `clang-format` |
| Crystal | `crystal_format` |
| Dart | `dart_format` |
| Elixir | `mix_format` |
| Gleam | `gleam_format` |
| Go | `gofmt`, `gofumpt` |
| HTML | `prettier` |
| JSON | `prettier`, `biome`, `clang-format`, `deno_fmt` |
| Java | `clang-format` |
| JavaScript | `prettier`, `biome`, `clang-format`, `deno_fmt` |
| Lua | `stylua` |
| Nim | `nimpretty` |
| Objective C | `clang-format` |
| Protobuf | `clang-format` |
| Python | `ruff`, `black`, `blue`, `yapf`, `autopep8` |
| Roc | `roc_format` |
| Ruby | `rubocop` |
| Rust | `rustfmt` |
| SQL | `sqlfluff`, `sql-formatter` |
| Shell | `shfmt` |
| TOML | `taplo` |
| TypeScript | `prettier`, `biome`, `deno_fmt` |
| Vue | `prettier` |
| YAML | `prettier` |
| Zig | `zigfmt` |
| Language | Formatters |
| ----------- | ------------------------------------------------------------- |
| C | `clang-format` |
| Cpp | `clang-format` |
| Crystal | `crystal_format` |
| CSharp | `clang-format` |
| CSS | `prettier` |
| Dart | `dart_format` |
| Elixir | `mix_format` |
| Gleam | `gleam_format` |
| Go | `gofmt`, `gofumpt` |
| HTML | `prettier` |
| Java | `clang-format` |
| JavaScript | `prettier`, `biome`, `clang-format`, `deno_fmt` |
| JSON | `prettier`, `biome`, `clang-format`, `deno_fmt` |
| Lua | `stylua` |
| Nim | `nimpretty` |
| Objective C | `clang-format` |
| Protobuf | `clang-format` |
| Python | `ruff`, `black`, `blue`, `yapf`, `autopep8`, `isort`, `usort` |
| Roc | `roc_format` |
| Ruby | `rubocop` |
| Rust | `rustfmt` |
| Shell | `shfmt` |
| SQL | `sqlfluff`, `sql-formatter` |
| TOML | `taplo` |
| TypeScript | `prettier`, `biome`, `deno_fmt` |
| Vue | `prettier` |
| YAML | `prettier` |
| Zig | `zigfmt` |
7 changes: 7 additions & 0 deletions mdsf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "https://raw.githubusercontent.com/hougesen/mdsf/main/schemas/v0.0.1/mdsf.schema.json",
"markdown": {
"enabled": false,
"formatter": []
}
}
4 changes: 2 additions & 2 deletions schemas/v0.0.1/mdsf.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
"javascript": {
"default": {
"enabled": true,
"formatter": [["biome", "prettier", "deno_fmt", "clang-format"]]
"formatter": [["prettier", "biome", "deno_fmt", "clang-format"]]
},
"allOf": [
{
Expand Down Expand Up @@ -284,7 +284,7 @@
"typescript": {
"default": {
"enabled": true,
"formatter": [["biome", "prettier", "deno_fmt"]]
"formatter": [["prettier", "biome", "deno_fmt"]]
},
"allOf": [
{
Expand Down
2 changes: 1 addition & 1 deletion src/languages/javascript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ impl Default for MdsfFormatter<JavaScript> {
#[inline]
fn default() -> Self {
Self::Multiple(vec![Self::Multiple(vec![
Self::Single(JavaScript::Biome),
Self::Single(JavaScript::Prettier),
Self::Single(JavaScript::Biome),
Self::Single(JavaScript::DenoFmt),
Self::Single(JavaScript::ClangFormat),
])])
Expand Down
2 changes: 1 addition & 1 deletion src/languages/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ impl Default for MdsfFormatter<TypeScript> {
#[inline]
fn default() -> Self {
Self::Multiple(vec![Self::Multiple(vec![
Self::Single(TypeScript::Biome),
Self::Single(TypeScript::Prettier),
Self::Single(TypeScript::Biome),
Self::Single(TypeScript::DenoFmt),
])])
}
Expand Down

0 comments on commit b36f9ff

Please sign in to comment.