diff --git a/README.md b/README.md index cded2395..9df835f9 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ mdsf init -`mdsf` currently supports 145 tools. +`mdsf` currently supports 146 tools. | Formatter | Description | | ------------------ | ---------------------------------------------------------------------------------------------------------------------- | @@ -244,6 +244,7 @@ mdsf init | uiua_fmt | [https://github.com/uiua-lang/uiua](https://github.com/uiua-lang/uiua) | | usort | [https://github.com/facebook/usort](https://github.com/facebook/usort) | | veryl_fmt | [https://github.com/veryl-lang/veryl](https://github.com/veryl-lang/veryl) | +| vlang_fmt | [https://vlang.io](https://vlang.io) | | xmlformat | [https://github.com/pamoller/xmlformatter](https://github.com/pamoller/xmlformatter) | | xmllint | [http://xmlsoft.org/xmllint.html](http://xmlsoft.org/xmllint.html) | | xo | [http://github.com/xojs/xo](http://github.com/xojs/xo) | diff --git a/schemas/v0.1.2/mdsf.schema.json b/schemas/v0.1.2/mdsf.schema.json index 91fa9500..06c6e744 100644 --- a/schemas/v0.1.2/mdsf.schema.json +++ b/schemas/v0.1.2/mdsf.schema.json @@ -724,6 +724,11 @@ "type": "string", "enum": ["usort"] }, + { + "description": "https://vlang.io", + "type": "string", + "enum": ["vlang_fmt"] + }, { "description": "https://github.com/veryl-lang/veryl", "type": "string", diff --git a/src/formatters/mod.rs b/src/formatters/mod.rs index 6eeafa96..035412d0 100644 --- a/src/formatters/mod.rs +++ b/src/formatters/mod.rs @@ -143,6 +143,7 @@ mod ts_standard; mod typos; mod uiua; mod usort; +mod v; mod veryl; mod xmlformat; mod xmllint; @@ -812,6 +813,10 @@ pub enum Tooling { #[serde(rename = "usort")] Usort, + #[doc = "https://vlang.io"] + #[serde(rename = "vlang_fmt")] + VlangFmt, + #[doc = "https://github.com/veryl-lang/veryl"] #[serde(rename = "veryl_fmt")] VerylFmt, @@ -996,6 +1001,7 @@ impl Tooling { Self::Typos => typos::run(snippet_path), Self::UiuaFmt => uiua::run_fmt(snippet_path), Self::Usort => usort::run(snippet_path), + Self::VlangFmt => v::run_fmt(snippet_path), Self::VerylFmt => veryl::run_fmt(snippet_path), Self::XmlFormat => xmlformat::run(snippet_path), Self::XmlLint => xmllint::run(snippet_path), @@ -1150,6 +1156,7 @@ impl core::fmt::Display for Tooling { Self::Typos => write!(f, "typos"), Self::UiuaFmt => write!(f, "uiua_fmt"), Self::Usort => write!(f, "usort"), + Self::VlangFmt => write!(f, "vlang_fmt"), Self::VerylFmt => write!(f, "veryl_fmt"), Self::XmlFormat => write!(f, "xmlformat"), Self::XmlLint => write!(f, "xmllint"), diff --git a/src/formatters/v.rs b/src/formatters/v.rs new file mode 100644 index 00000000..30ddae09 --- /dev/null +++ b/src/formatters/v.rs @@ -0,0 +1,11 @@ +use super::execute_command; +use crate::error::MdsfError; + +#[inline] +pub fn run_fmt(snippet_path: &std::path::Path) -> Result<(bool, Option), MdsfError> { + let mut cmd = std::process::Command::new("v"); + + cmd.arg("fmt").arg("-w").arg(snippet_path); + + execute_command(&mut cmd, snippet_path) +}