Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(formatters): support ziggy fmt #481

Merged
merged 1 commit into from
Oct 11, 2024
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [Unreleased](https://github.com/hougesen/mdsf/compare/v0.2.6...HEAD)

- feat(formatters): support kulala-fmt [`#480`](https://github.com/hougesen/mdsf/pull/480)
- feat(formatters): support superhtml [`#479`](https://github.com/hougesen/mdsf/pull/479)
- refactor: make language_to_ext return type optional [`#478`](https://github.com/hougesen/mdsf/pull/478)
- feat(formatters): support mojo format [`#477`](https://github.com/hougesen/mdsf/pull/477)
- feat(formatters): support kulala-fmt (#480) [`#157`](https://github.com/hougesen/mdsf/issues/157)
- chore: bump dev version to 0.2.7 [`305275a`](https://github.com/hougesen/mdsf/commit/305275a64ae2aa8b60c2dca463412361cf6d02ee)

#### [v0.2.6](https://github.com/hougesen/mdsf/compare/v0.2.5...v0.2.6)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ mdsf init

<!-- START_SECTION:supported-tools -->

`mdsf` currently supports 178 tools. Feel free to open an issue/pull-request if your favorite tool is missing! 😃
`mdsf` currently supports 179 tools. Feel free to open an issue/pull-request if your favorite tool is missing! 😃

| Formatter | Description |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
Expand Down Expand Up @@ -365,6 +365,7 @@ mdsf init
| yapf | [https://github.com/google/yapf](https://github.com/google/yapf) |
| yew-fmt | [https://github.com/its-the-shrimp/yew-fmt](https://github.com/its-the-shrimp/yew-fmt) |
| zigfmt | [https://ziglang.org/](https://ziglang.org/) |
| ziggy_fmt | [https://ziggy-lang.io/documentation/ziggy-fmt/](https://ziggy-lang.io/documentation/ziggy-fmt/) |
| zprint | [https://github.com/kkinnear/zprint](https://github.com/kkinnear/zprint) |

<!-- END_SECTION:supported-tools -->
Expand Down
67 changes: 37 additions & 30 deletions mdsf/src/formatters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ mod yamlfmt;
mod yapf;
mod yew_fmt;
mod zigfmt;
mod ziggy;
mod zprint;

#[inline]
Expand Down Expand Up @@ -1068,6 +1069,10 @@ pub enum Tooling {
#[serde(rename = "zigfmt")]
ZigFmt,

#[doc = "https://ziggy-lang.io/documentation/ziggy-fmt/"]
#[serde(rename = "ziggy_fmt")]
ZiggyFmt,

#[doc = "https://github.com/kkinnear/zprint"]
#[serde(rename = "zprint")]
Zprint,
Expand Down Expand Up @@ -1099,10 +1104,10 @@ impl Tooling {
Self::BladeFormatter => blade_formatter::run(snippet_path),
Self::Blue => blue::run(snippet_path),
Self::Bpfmt => bpfmt::run(snippet_path),
Self::Brittany => brittany::run(snippet_path),
Self::Bsfmt => bsfmt::run(snippet_path),
Self::Buf => buf::run(snippet_path),
Self::Buildifier => buildifier::run(snippet_path),
Self::Brittany => brittany::run(snippet_path),
Self::CSharpier => csharpier::run(snippet_path),
Self::CabalFormat => cabal_format::run(snippet_path),
Self::CaramelFmt => caramel::run_fmt(snippet_path),
Expand All @@ -1117,13 +1122,13 @@ impl Tooling {
Self::Csscomb => csscomb::run(snippet_path),
Self::D2 => d2::run(snippet_path),
Self::DFmt => dfmt::run(snippet_path),
Self::Dhall => dhall::run(snippet_path),
Self::DartFix => dart::run_fix(snippet_path),
Self::DartFormat => dart::run_format(snippet_path),
Self::DcmFix => dcm::run_fix(snippet_path),
Self::DcmFormat => dcm::run_format(snippet_path),
Self::DenoFmt => deno::run_fmt(snippet_path),
Self::DenoLint => deno::run_lint(snippet_path),
Self::Dhall => dhall::run(snippet_path),
Self::DjLint => djlint::run(snippet_path),
Self::Docformatter => docformatter::run(snippet_path),
Self::Docstrfmt => docstrfmt::run(snippet_path),
Expand All @@ -1139,11 +1144,11 @@ impl Tooling {
Self::Findent => findent::run(snippet_path),
Self::FishIndent => fish_indent::run(snippet_path),
Self::Fixjson => fixjson::run(snippet_path),
Self::Floskell => floskell::run(snippet_path),
Self::Fnlfmt => fnlfmt::run(snippet_path),
Self::ForgeFmt => forge_fmt::run(snippet_path),
Self::Fourmolu => fourmolu::run(snippet_path),
Self::Fprettify => fprettify::run(snippet_path),
Self::Floskell => floskell::run(snippet_path),
Self::GCI => gci::run(snippet_path),
Self::Gdformat => gdformat::run(snippet_path),
Self::Gersemi => gersemi::run(snippet_path),
Expand All @@ -1157,8 +1162,8 @@ impl Tooling {
Self::GoogleJavaFormat => google_java_format::run(snippet_path),
Self::GrainFormat => grain::run_format(snippet_path),
Self::HIndent => hindent::run(snippet_path),
Self::Hfmt => hfmt::run(snippet_path),
Self::HamlLint => haml_lint::run(snippet_path),
Self::Hfmt => hfmt::run(snippet_path),
Self::HtmlBeautify => html_beautify::run(snippet_path),
Self::Htmlbeautifier => htmlbeautifier::run(snippet_path),
Self::ImbaFmt => imba::run_fmt(snippet_path),
Expand Down Expand Up @@ -1206,8 +1211,8 @@ impl Tooling {
Self::Prisma => prisma::run_format(snippet_path),
Self::PuppetLint => puppet_lint::run(snippet_path),
Self::PursTidy => purs_tidy::run(snippet_path),
Self::Pycln => pycln::run(snippet_path),
Self::PyInk => pyink::run(snippet_path),
Self::Pycln => pycln::run(snippet_path),
Self::Qmlfmt => qmlfmt::run(snippet_path),
Self::RacoFmt => raco::run_fmt(snippet_path),
Self::ReScriptFormat => rescript_format::run(snippet_path),
Expand All @@ -1232,8 +1237,8 @@ impl Tooling {
Self::Sqlfmt => sqlfmt::run(snippet_path),
Self::Standardjs => standardjs::run(snippet_path),
Self::Standardrb => standardrb::run(snippet_path),
Self::Stylefmt => stylefmt::run(snippet_path),
Self::StyleLint => stylelint::run(snippet_path),
Self::Stylefmt => stylefmt::run(snippet_path),
Self::StylishHaskell => stylish_haskell::run(snippet_path),
Self::Stylua => stylua::run(snippet_path),
Self::SuperhtmlFmt => superhtml::run_fmt(snippet_path),
Expand All @@ -1258,6 +1263,7 @@ impl Tooling {
Self::Yapf => yapf::run(snippet_path),
Self::YewFmt => yew_fmt::run(snippet_path),
Self::ZigFmt => zigfmt::run(snippet_path),
Self::ZiggyFmt => ziggy::run_fmt(snippet_path),
Self::Zprint => zprint::run(snippet_path),
}
}
Expand Down Expand Up @@ -1286,10 +1292,10 @@ impl AsRef<str> for Tooling {
Self::BladeFormatter => "blade-formatter",
Self::Blue => "blue",
Self::Bpfmt => "bpfmt",
Self::Brittany => "brittany",
Self::Bsfmt => "bsfmt",
Self::Buf => "buf",
Self::Buildifier => "buildifier",
Self::Brittany => "brittany",
Self::CSharpier => "csharpier",
Self::CabalFormat => "cabal_format",
Self::CaramelFmt => "caramel_fmt",
Expand All @@ -1300,20 +1306,23 @@ impl AsRef<str> for Tooling {
Self::Codespell => "codespell",
Self::CrlFmt => "crlfmt",
Self::CrystalFormat => "crystal_format",
Self::CssBeautify => "css-beautify",
Self::Csscomb => "csscomb",
Self::D2 => "d2",
Self::DFmt => "dfmt",
Self::Dhall => "dhall",
Self::DartFormat => "dart_format",
Self::DartFix => "dart_fix",
Self::DartFormat => "dart_format",
Self::DcmFix => "dcm_fix",
Self::DcmFormat => "dcm_format",
Self::DenoFmt => "deno_fmt",
Self::DenoLint => "deno_lint",
Self::Dhall => "dhall",
Self::DjLint => "djlint",
Self::DcmFormat => "dcm_format",
Self::DcmFix => "dcm_fix",
Self::Docformatter => "docformatter",
Self::Docstrfmt => "docstrfmt",
Self::DotenvLinter => "dotenv-linter",
Self::Dprint => "dprint",
Self::EasyCodingStandard => "easy-coding-standard",
Self::Efmt => "efmt",
Self::ElmFormat => "elm-format",
Self::ErbFormatter => "erb-formatter",
Expand All @@ -1323,11 +1332,11 @@ impl AsRef<str> for Tooling {
Self::Findent => "findent",
Self::FishIndent => "fish_indent",
Self::Fixjson => "fixjson",
Self::Floskell => "floskell",
Self::Fnlfmt => "fnlfmt",
Self::ForgeFmt => "forge_fmt",
Self::Fourmolu => "fourmolu",
Self::Fprettify => "fprettify",
Self::Floskell => "floskell",
Self::GCI => "gci",
Self::Gdformat => "gdformat",
Self::Gersemi => "gersemi",
Expand All @@ -1341,16 +1350,18 @@ impl AsRef<str> for Tooling {
Self::GoogleJavaFormat => "google-java-format",
Self::GrainFormat => "grain_format",
Self::HIndent => "hindent",
Self::Hfmt => "hfmt",
Self::HamlLint => "haml-lint",
Self::Hfmt => "hfmt",
Self::HtmlBeautify => "html-beautify",
Self::Htmlbeautifier => "htmlbeautifier",
Self::ImbaFmt => "imba_fmt",
Self::Isort => "isort",
Self::Joker => "joker",
Self::JuliaFormatterJl => "juliaformatter.jl",
Self::JustFmt => "just_fmt",
Self::JsBeautify => "js-beautify",
Self::JsonaFormat => "jsona_format",
Self::Jsonnetfmt => "jsonnetfmt",
Self::JuliaFormatterJl => "juliaformatter.jl",
Self::JustFmt => "just_fmt",
Self::KclFmt => "kcl_fmt",
Self::Kdlfmt => "kdlfmt",
Self::Ktfmt => "ktfmt",
Expand Down Expand Up @@ -1379,12 +1390,17 @@ impl AsRef<str> for Tooling {
Self::PackerFmt => "packer_fmt",
Self::PerlTidy => "perltidy",
Self::PgFormat => "pg_format",
Self::PhpCsFixer => "php-cs-fixer",
Self::Phpcbf => "phpcbf",
Self::Phpinsights => "phpinsights",
Self::Pint => "pint",
Self::Prettier => "prettier",
Self::PrettyPhp => "pretty-php",
Self::Prisma => "prisma",
Self::PuppetLint => "puppet-lint",
Self::PursTidy => "purs-tidy",
Self::Pycln => "pycln",
Self::PyInk => "pyink",
Self::Pycln => "pycln",
Self::Qmlfmt => "qmlfmt",
Self::RacoFmt => "raco_fmt",
Self::ReScriptFormat => "rescript_format",
Expand All @@ -1409,22 +1425,24 @@ impl AsRef<str> for Tooling {
Self::Sqlfmt => "sqlfmt",
Self::Standardjs => "standardjs",
Self::Standardrb => "standardrb",
Self::Stylefmt => "stylefmt",
Self::StyleLint => "stylelint",
Self::Stylefmt => "stylefmt",
Self::StylishHaskell => "stylish-haskell",
Self::Stylua => "stylua",
Self::SuperhtmlFmt => "superhtml_fmt",
Self::Taplo => "taplo",
Self::Templ => "templ",
Self::TerraformFmt => "terraform_fmt",
Self::Tlint => "tlint",
Self::TofuFmt => "tofu_fmt",
Self::Topiary => "topiary",
Self::TsStandard => "ts-standard",
Self::TwigCsFixer => "twig-cs-fixer",
Self::Typos => "typos",
Self::UiuaFmt => "uiua_fmt",
Self::Usort => "usort",
Self::VlangFmt => "vlang_fmt",
Self::VerylFmt => "veryl_fmt",
Self::VlangFmt => "vlang_fmt",
Self::XmlFormat => "xmlformat",
Self::XmlLint => "xmllint",
Self::Xo => "xo",
Expand All @@ -1433,19 +1451,8 @@ impl AsRef<str> for Tooling {
Self::Yapf => "yapf",
Self::YewFmt => "yew-fmt",
Self::ZigFmt => "zigfmt",
Self::ZiggyFmt => "ziggy_fmt",
Self::Zprint => "zprint",
Self::CssBeautify => "css-beautify",
Self::Csscomb => "csscomb",
Self::EasyCodingStandard => "easy-coding-standard",
Self::HtmlBeautify => "html-beautify",
Self::JsBeautify => "js-beautify",
Self::PhpCsFixer => "php-cs-fixer",
Self::Phpcbf => "phpcbf",
Self::Phpinsights => "phpinsights",
Self::Pint => "pint",
Self::PrettyPhp => "pretty-php",
Self::Tlint => "tlint",
Self::TwigCsFixer => "twig-cs-fixer",
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions mdsf/src/formatters/ziggy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use super::execute_command;
use crate::{error::MdsfError, runners::CommandType};

#[inline]
pub fn run_fmt(file_path: &std::path::Path) -> Result<(bool, Option<String>), MdsfError> {
let mut cmd = CommandType::Direct("ziggy").build();

cmd.arg("fmt").arg(file_path);

execute_command(cmd, file_path)
}
5 changes: 5 additions & 0 deletions schemas/v0.2.7/mdsf.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,11 @@
"type": "string",
"enum": ["zigfmt"]
},
{
"description": "https://ziggy-lang.io/documentation/ziggy-fmt/",
"type": "string",
"enum": ["ziggy_fmt"]
},
{
"description": "https://github.com/kkinnear/zprint",
"type": "string",
Expand Down
Loading