From f773bd4c64d04b493b9b188af4a39688d82b7ebf Mon Sep 17 00:00:00 2001 From: Mads Hougesen Date: Thu, 21 Mar 2024 15:19:07 +0100 Subject: [PATCH] fix: use correct formatter --- README.md | 3 ++- schemas/v0.0.2/mdsf.schema.json | 44 +++++++++++++++++++++++++++++++-- src/languages/erlang.rs | 8 +++--- 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 4c64a36c..abddcb67 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,7 @@ mdsf init | Dart | `dart_format` | | Elixir | `mix_format` | | Elm | `elm-format` | +| Erlang | `erlfmt` | | Gleam | `gleam_format` | | Go | `gofmt`, `gofumpt`, `goimports` | | GraphQL | `prettier` | @@ -94,7 +95,7 @@ mdsf init | Python | `autopep8`, `black`, `blue`, `isort`, `ruff`, `usort`, `yapf` | | ReScript | `rescript_format` | | Roc | `roc_format` | -| Ruby | `rubocop`, `rubyfmt`, `rufo` | +| Ruby | `rubocop`, `rubyfmt`, `rufo`, `standardrb` | | Rust | `rustfmt` | | Scala | `scalafmt` | | Shell | `beautysh`, `shfmt` | diff --git a/schemas/v0.0.2/mdsf.schema.json b/schemas/v0.0.2/mdsf.schema.json index 43ffb4c5..599cb50c 100644 --- a/schemas/v0.0.2/mdsf.schema.json +++ b/schemas/v0.0.2/mdsf.schema.json @@ -113,6 +113,17 @@ } ] }, + "erlang": { + "default": { + "enabled": true, + "formatter": "erlfmt" + }, + "allOf": [ + { + "$ref": "#/definitions/Lang_for_Erlang" + } + ] + }, "gleam": { "default": { "enabled": true, @@ -361,7 +372,7 @@ "ruby": { "default": { "enabled": true, - "formatter": [["rubocop", "rufo", "rubyfmt"]] + "formatter": [["rubocop", "rufo", "rubyfmt", "standardrb"]] }, "allOf": [ { @@ -532,6 +543,10 @@ "type": "string", "enum": ["elm-format"] }, + "Erlang": { + "type": "string", + "enum": ["erlfmt"] + }, "Gleam": { "type": "string", "enum": ["gleam_format"] @@ -696,6 +711,18 @@ } } }, + "Lang_for_Erlang": { + "type": "object", + "required": ["enabled", "formatter"], + "properties": { + "enabled": { + "type": "boolean" + }, + "formatter": { + "$ref": "#/definitions/MdsfFormatter_for_Erlang" + } + } + }, "Lang_for_Gleam": { "type": "object", "required": ["enabled", "formatter"], @@ -1242,6 +1269,19 @@ } ] }, + "MdsfFormatter_for_Erlang": { + "anyOf": [ + { + "$ref": "#/definitions/Erlang" + }, + { + "type": "array", + "items": { + "$ref": "#/definitions/MdsfFormatter_for_Erlang" + } + } + ] + }, "MdsfFormatter_for_Gleam": { "anyOf": [ { @@ -1722,7 +1762,7 @@ }, "Ruby": { "type": "string", - "enum": ["rubyfmt", "rubocop", "rufo"] + "enum": ["rubyfmt", "rubocop", "rufo", "standardrb"] }, "Rust": { "type": "string", diff --git a/src/languages/erlang.rs b/src/languages/erlang.rs index f6e3974e..c4bc429c 100644 --- a/src/languages/erlang.rs +++ b/src/languages/erlang.rs @@ -1,6 +1,6 @@ use schemars::JsonSchema; -use crate::formatters::{gleam_format::format_using_gleam_format, MdsfFormatter}; +use crate::formatters::{erlfmt::format_using_erlfmt, MdsfFormatter}; use super::{Lang, LanguageFormatter}; @@ -36,13 +36,13 @@ impl LanguageFormatter for Erlang { snippet_path: &std::path::Path, ) -> std::io::Result<(bool, Option)> { match self { - Self::Erlfmt => format_using_gleam_format(snippet_path), + Self::Erlfmt => format_using_erlfmt(snippet_path), } } } #[cfg(test)] -mod test_gleam { +mod test_erlang { use crate::{ formatters::{setup_snippet, MdsfFormatter}, languages::Lang, @@ -77,7 +77,7 @@ case Erlang of movie->[hello(mike,joe,robert),credits]; language->formatting_arg #[test_with::executable(erlfmt)] #[test] - fn test_gleam_format() { + fn test_erlfmt() { let l = Lang:: { enabled: true, formatter: MdsfFormatter::Single(Erlang::Erlfmt),