From b36f9ff81d41d3471432ecdefb8eb838f2e70f6b Mon Sep 17 00:00:00 2001 From: Mads Hougesen Date: Sat, 16 Mar 2024 01:12:26 +0100 Subject: [PATCH] docs: document formatter configuration --- README.md | 72 ++++++++++++++++++++------------- mdsf.json | 7 ++++ schemas/v0.0.1/mdsf.schema.json | 4 +- src/languages/javascript.rs | 2 +- src/languages/typescript.rs | 2 +- 5 files changed, 54 insertions(+), 33 deletions(-) create mode 100644 mdsf.json diff --git a/README.md b/README.md index 4c78660..9a756ea 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,19 @@ 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\] @@ -45,32 +58,33 @@ mdsf init > > 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` | diff --git a/mdsf.json b/mdsf.json new file mode 100644 index 0000000..ed366ef --- /dev/null +++ b/mdsf.json @@ -0,0 +1,7 @@ +{ + "$schema": "https://raw.githubusercontent.com/hougesen/mdsf/main/schemas/v0.0.1/mdsf.schema.json", + "markdown": { + "enabled": false, + "formatter": [] + } +} diff --git a/schemas/v0.0.1/mdsf.schema.json b/schemas/v0.0.1/mdsf.schema.json index f60eab4..fb23b9b 100644 --- a/schemas/v0.0.1/mdsf.schema.json +++ b/schemas/v0.0.1/mdsf.schema.json @@ -127,7 +127,7 @@ "javascript": { "default": { "enabled": true, - "formatter": [["biome", "prettier", "deno_fmt", "clang-format"]] + "formatter": [["prettier", "biome", "deno_fmt", "clang-format"]] }, "allOf": [ { @@ -284,7 +284,7 @@ "typescript": { "default": { "enabled": true, - "formatter": [["biome", "prettier", "deno_fmt"]] + "formatter": [["prettier", "biome", "deno_fmt"]] }, "allOf": [ { diff --git a/src/languages/javascript.rs b/src/languages/javascript.rs index 52c50e1..d09cb10 100644 --- a/src/languages/javascript.rs +++ b/src/languages/javascript.rs @@ -35,8 +35,8 @@ impl Default for MdsfFormatter { #[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), ])]) diff --git a/src/languages/typescript.rs b/src/languages/typescript.rs index 59a0e76..fba08db 100644 --- a/src/languages/typescript.rs +++ b/src/languages/typescript.rs @@ -33,8 +33,8 @@ impl Default for MdsfFormatter { #[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), ])]) }