Skip to content

Commit

Permalink
fix: use correct formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
hougesen committed Mar 21, 2024
1 parent 280ed44 commit f773bd4
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 7 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` |
Expand All @@ -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` |
Expand Down
44 changes: 42 additions & 2 deletions schemas/v0.0.2/mdsf.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@
}
]
},
"erlang": {
"default": {
"enabled": true,
"formatter": "erlfmt"
},
"allOf": [
{
"$ref": "#/definitions/Lang_for_Erlang"
}
]
},
"gleam": {
"default": {
"enabled": true,
Expand Down Expand Up @@ -361,7 +372,7 @@
"ruby": {
"default": {
"enabled": true,
"formatter": [["rubocop", "rufo", "rubyfmt"]]
"formatter": [["rubocop", "rufo", "rubyfmt", "standardrb"]]
},
"allOf": [
{
Expand Down Expand Up @@ -532,6 +543,10 @@
"type": "string",
"enum": ["elm-format"]
},
"Erlang": {
"type": "string",
"enum": ["erlfmt"]
},
"Gleam": {
"type": "string",
"enum": ["gleam_format"]
Expand Down Expand Up @@ -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"],
Expand Down Expand Up @@ -1242,6 +1269,19 @@
}
]
},
"MdsfFormatter_for_Erlang": {
"anyOf": [
{
"$ref": "#/definitions/Erlang"
},
{
"type": "array",
"items": {
"$ref": "#/definitions/MdsfFormatter_for_Erlang"
}
}
]
},
"MdsfFormatter_for_Gleam": {
"anyOf": [
{
Expand Down Expand Up @@ -1722,7 +1762,7 @@
},
"Ruby": {
"type": "string",
"enum": ["rubyfmt", "rubocop", "rufo"]
"enum": ["rubyfmt", "rubocop", "rufo", "standardrb"]
},
"Rust": {
"type": "string",
Expand Down
8 changes: 4 additions & 4 deletions src/languages/erlang.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down Expand Up @@ -36,13 +36,13 @@ impl LanguageFormatter for Erlang {
snippet_path: &std::path::Path,
) -> std::io::Result<(bool, Option<String>)> {
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,
Expand Down Expand Up @@ -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::<Erlang> {
enabled: true,
formatter: MdsfFormatter::Single(Erlang::Erlfmt),
Expand Down

0 comments on commit f773bd4

Please sign in to comment.