diff --git a/CHANGELOG.md b/CHANGELOG.md index f0f21d9..7a900d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). #### [Unreleased](https://github.com/hougesen/mdsf/compare/v0.4.0...HEAD) +- feat: add support for inko fmt [`#610`](https://github.com/hougesen/mdsf/pull/610) - feat: add support for futhark fmt [`#609`](https://github.com/hougesen/mdsf/pull/609) - feat: add support for wa fmt [`#608`](https://github.com/hougesen/mdsf/pull/608) - feat: add support for selena [`#607`](https://github.com/hougesen/mdsf/pull/607) diff --git a/README.md b/README.md index 74aa1ac..2b50b87 100644 --- a/README.md +++ b/README.md @@ -214,7 +214,7 @@ mdsf init -`mdsf` currently supports 238 tools. Feel free to open an issue/pull-request if your favorite tool/command is missing! 😃 +`mdsf` currently supports 239 tools. Feel free to open an issue/pull-request if your favorite tool/command is missing! 😃 | Name | Description | Categories | Languages | | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | ------------------------------------------------------------------------- | @@ -312,6 +312,7 @@ mdsf init | [htmlbeautifier](https://github.com/threedaymonk/htmlbeautifier) | A normaliser/beautifier for HTML that also understands embedded Ruby. Ideal for tidying up Rails templates | `formatter` | `erb`, `html`, `ruby` | | [htmlhint](https://github.com/HTMLHint/HTMLHint) | The static code analysis tool you need for your HTML | `linter` | `html` | | [imba](https://imba.io/) | A formatter for Imba | `formatter` | `imba` | +| [inko](https://github.com/inko-lang/inko) | Code formatter for the inko programming language | `formatter` | `inko` | | [isort](https://github.com/timothycrosley/isort) | A Python utility to sort imports | `formatter` | `python` | | [joker](https://github.com/candid82/joker) | Small Clojure interpreter, linter and formatter | `formatter`, `linter` | `clojure` | | [js-beautify](https://github.com/beautifier/js-beautify) | A JavaScript formatter | `formatter` | `javascript` | diff --git a/mdsf/src/tools/inko_fmt.rs b/mdsf/src/tools/inko_fmt.rs new file mode 100644 index 0000000..454ba84 --- /dev/null +++ b/mdsf/src/tools/inko_fmt.rs @@ -0,0 +1,35 @@ +use std::process::Command; + +use crate::{error::MdsfError, execution::execute_command, runners::CommandType}; + +#[inline] +fn set_inko_fmt_args(mut cmd: Command, file_path: &std::path::Path) -> Command { + cmd.arg("fmt"); + cmd.arg(file_path); + cmd +} + +#[inline] +pub fn run(file_path: &std::path::Path) -> Result<(bool, Option), MdsfError> { + let commands = [CommandType::Direct("inko")]; + + for (index, cmd) in commands.iter().enumerate() { + let cmd = set_inko_fmt_args(cmd.build(), file_path); + let execution_result = execute_command(cmd, file_path); + + if index == commands.len() - 1 { + return execution_result; + } + + if let Ok(r) = execution_result { + if !r.0 { + return Ok(r); + } + } + } + + Ok((true, None)) +} + +#[cfg(test)] +mod test_inko_fmt {} diff --git a/mdsf/src/tools/mod.rs b/mdsf/src/tools/mod.rs index a52ffc6..48058de 100644 --- a/mdsf/src/tools/mod.rs +++ b/mdsf/src/tools/mod.rs @@ -97,6 +97,7 @@ pub mod html_beautify; pub mod htmlbeautifier; pub mod htmlhint; pub mod imba_fmt; +pub mod inko_fmt; pub mod isort; pub mod joker; pub mod js_beautify; @@ -648,6 +649,10 @@ pub enum Tooling { /// `imba fmt -f $PATH` ImbaFmt, + #[serde(rename = "inko:fmt")] + /// `inko fmt $PATH` + InkoFmt, + #[serde(rename = "isort")] /// `isort --quiet $PATH` Isort, @@ -1356,6 +1361,7 @@ impl Tooling { Self::Htmlbeautifier => htmlbeautifier::run(snippet_path), Self::Htmlhint => htmlhint::run(snippet_path), Self::ImbaFmt => imba_fmt::run(snippet_path), + Self::InkoFmt => inko_fmt::run(snippet_path), Self::Isort => isort::run(snippet_path), Self::Joker => joker::run(snippet_path), Self::JsBeautify => js_beautify::run(snippet_path), @@ -1614,6 +1620,7 @@ impl AsRef for Tooling { Self::Htmlbeautifier => "htmlbeautifier", Self::Htmlhint => "htmlhint", Self::ImbaFmt => "imba_fmt", + Self::InkoFmt => "inko_fmt", Self::Isort => "isort", Self::Joker => "joker", Self::JsBeautify => "js_beautify", diff --git a/schemas/v0.4.0-dev/mdsf.schema.json b/schemas/v0.4.0-dev/mdsf.schema.json index 754f478..11c148c 100644 --- a/schemas/v0.4.0-dev/mdsf.schema.json +++ b/schemas/v0.4.0-dev/mdsf.schema.json @@ -553,6 +553,11 @@ "type": "string", "enum": ["imba:fmt"] }, + { + "description": "`inko fmt $PATH`", + "type": "string", + "enum": ["inko:fmt"] + }, { "description": "`isort --quiet $PATH`", "type": "string", diff --git a/tools/inko/plugin.json b/tools/inko/plugin.json new file mode 100644 index 0000000..bff51e4 --- /dev/null +++ b/tools/inko/plugin.json @@ -0,0 +1,15 @@ +{ + "$schema": "../tool.schema.json", + "binary": "inko", + "categories": ["formatter"], + "commands": { + "fmt": ["fmt", "$PATH"] + }, + "description": "Code formatter for the inko programming language", + "homepage": "https://github.com/inko-lang/inko", + "languages": ["inko"], + "name": null, + "npm": null, + "php": null, + "tests": [] +}