Skip to content

Commit

Permalink
feat: add support for tex-fmt (#580)
Browse files Browse the repository at this point in the history
  • Loading branch information
hougesen authored Jan 12, 2025
1 parent 84b9366 commit 6ff4379
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 1 deletion.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

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

- feat: add support for tex-fmt [`#580`](https://github.com/hougesen/mdsf/pull/580)
- build(deps): bump clap from 4.5.21 to 4.5.26 [`#571`](https://github.com/hougesen/mdsf/pull/571)
- build(deps): bump tempfile from 3.14.0 to 3.15.0 [`#573`](https://github.com/hougesen/mdsf/pull/573)
- build(deps): bump serde from 1.0.215 to 1.0.217 [`#567`](https://github.com/hougesen/mdsf/pull/567)
- build(deps): bump env_logger from 0.11.5 to 0.11.6 [`#561`](https://github.com/hougesen/mdsf/pull/561)
- build(deps): bump anyhow from 1.0.93 to 1.0.95 [`#564`](https://github.com/hougesen/mdsf/pull/564)
- build(deps): bump reqwest from 0.12.9 to 0.12.12 [`#566`](https://github.com/hougesen/mdsf/pull/566)
- build(deps): bump test-with from 0.14.5 to 0.14.7 [`#574`](https://github.com/hougesen/mdsf/pull/574)
- feat: add packer fix command [`#579`](https://github.com/hougesen/mdsf/pull/579)
- feat: support nomad fmt [`#578`](https://github.com/hougesen/mdsf/pull/578)
- build(deps): bump serde_json from 1.0.133 to 1.0.135 [`#575`](https://github.com/hougesen/mdsf/pull/575)
- build(deps): bump clap_complete from 4.5.38 to 4.5.42 [`#572`](https://github.com/hougesen/mdsf/pull/572)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ mdsf init
<!-- START_SECTION:supported-tools -->

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

| Name | Description | Categories | Languages |
| --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | ------------------------------------------------------------------------- |
Expand Down Expand Up @@ -402,6 +402,7 @@ mdsf init
| [templ](https://templ.guide/) | Tooling for the Templ template language | `formatter` | `go`, `templ` |
| [terraform](https://www.terraform.io/docs/cli/commands/fmt.html) | The terraform fmt command is used to rewrite Terraform configuration files to a canonical format and style | `formatter` | `terraform` |
| [terragrunt](https://terragrunt.gruntwork.io/docs/reference/cli-options/#hclfmt) | Recursively find hcl files and rewrite them into a canonical format | `formatter` | `hcl` |
| [tex-fmt](https://github.com/WGUNDERWOOD/tex-fmt) | An extremely fast LaTeX formatter written in Rust | `formatter` | `latex` |
| [tlint](https://github.com/tighten/tlint) | Tighten linter for Laravel conventions | `linter` | `php` |
| [tofu](https://opentofu.org/docs/cli/commands/fmt/) | The tofu fmt command is used to rewrite OpenTofu configuration files to a canonical format and style | `formatter` | `terraform`, `tofu` |
| [topiary](https://github.com/tweag/topiary) | Topiary aims to be a uniform formatter for simple languages, as part of the Tree-sitter ecosystem | `formatter` | |
Expand Down
7 changes: 7 additions & 0 deletions mdsf/src/tools/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ pub mod taplo;
pub mod templ_fmt;
pub mod terraform_fmt;
pub mod terragrunt_hclfmt;
pub mod tex_fmt;
pub mod tlint_format;
pub mod tofu_fmt;
pub mod topiary;
Expand Down Expand Up @@ -1000,6 +1001,10 @@ pub enum Tooling {
/// `terragrunt hclfmt --terragrunt-hclfmt-file $PATH`
TerragruntHclfmt,

#[serde(rename = "tex-fmt")]
/// `tex-fmt $PATH`
TexFmt,

#[serde(rename = "tlint:format")]
/// `tlint format $PATH`
TlintFormat,
Expand Down Expand Up @@ -1311,6 +1316,7 @@ impl Tooling {
Self::TemplFmt => templ_fmt::run(snippet_path),
Self::TerraformFmt => terraform_fmt::run(snippet_path),
Self::TerragruntHclfmt => terragrunt_hclfmt::run(snippet_path),
Self::TexFmt => tex_fmt::run(snippet_path),
Self::TlintFormat => tlint_format::run(snippet_path),
Self::TofuFmt => tofu_fmt::run(snippet_path),
Self::Topiary => topiary::run(snippet_path),
Expand Down Expand Up @@ -1541,6 +1547,7 @@ impl AsRef<str> for Tooling {
Self::TemplFmt => "templ_fmt",
Self::TerraformFmt => "terraform_fmt",
Self::TerragruntHclfmt => "terragrunt_hclfmt",
Self::TexFmt => "tex_fmt",
Self::TlintFormat => "tlint_format",
Self::TofuFmt => "tofu_fmt",
Self::Topiary => "topiary",
Expand Down
34 changes: 34 additions & 0 deletions mdsf/src/tools/tex_fmt.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use std::process::Command;

use crate::{error::MdsfError, execution::execute_command, runners::CommandType};

#[inline]
fn set_tex_fmt_args(mut cmd: Command, file_path: &std::path::Path) -> Command {
cmd.arg(file_path);
cmd
}

#[inline]
pub fn run(file_path: &std::path::Path) -> Result<(bool, Option<String>), MdsfError> {
let commands = [CommandType::Direct("tex-fmt")];

for (index, cmd) in commands.iter().enumerate() {
let cmd = set_tex_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_tex_fmt {}
5 changes: 5 additions & 0 deletions schemas/v0.3.3-dev/mdsf.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,11 @@
"type": "string",
"enum": ["terragrunt:hclfmt"]
},
{
"description": "`tex-fmt $PATH`",
"type": "string",
"enum": ["tex-fmt"]
},
{
"description": "`tlint format $PATH`",
"type": "string",
Expand Down
15 changes: 15 additions & 0 deletions tools/tex-fmt/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "../tool.schema.json",
"binary": "tex-fmt",
"categories": ["formatter"],
"commands": {
"": ["$PATH"]
},
"description": "An extremely fast LaTeX formatter written in Rust",
"homepage": "https://github.com/WGUNDERWOOD/tex-fmt",
"languages": ["latex"],
"name": null,
"npm": null,
"php": null,
"tests": []
}

0 comments on commit 6ff4379

Please sign in to comment.