Skip to content

Commit

Permalink
feat(nickel): support nickel format (#317)
Browse files Browse the repository at this point in the history
  • Loading branch information
hougesen authored Jun 20, 2024
1 parent bb874dd commit 4883e31
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ mdsf init
<!-- START_SECTION:supported-languages -->

`mdsf` currently supports 138 tools.
`mdsf` currently supports 139 tools.

| Formatter | Description |
| ------------------ | ---------------------------------------------------------------------------------------------------------------------- |
Expand Down Expand Up @@ -192,6 +192,7 @@ mdsf init
| mdformat | [https://github.com/executablebooks/mdformat](https://github.com/executablebooks/mdformat) |
| misspell | [https://github.com/client9/misspell/](https://github.com/client9/misspell/) |
| mix_format | [https://hexdocs.pm/mix/main/Mix.Tasks.Format.html](https://hexdocs.pm/mix/main/Mix.Tasks.Format.html) |
| nickel_format | [https://nickel-lang.org](https://nickel-lang.org) |
| nimpretty | [https://github.com/nim-lang/nim](https://github.com/nim-lang/nim) |
| nixfmt | [https://github.com/serokell/nixfmt](https://github.com/serokell/nixfmt) |
| nixpkgs-fmt | [https://github.com/nix-community/nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt) |
Expand Down
5 changes: 5 additions & 0 deletions schemas/v0.1.2/mdsf.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,11 @@
"type": "string",
"enum": ["mix_format"]
},
{
"description": "https://nickel-lang.org",
"type": "string",
"enum": ["nickel_format"]
},
{
"description": "https://github.com/nim-lang/nim",
"type": "string",
Expand Down
7 changes: 7 additions & 0 deletions src/formatters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ mod markuplint;
mod mdformat;
mod misspell;
mod mix_format;
mod nickel;
mod nimpretty;
mod nixfmt;
mod nixpkgs_fmt;
Expand Down Expand Up @@ -601,6 +602,10 @@ pub enum Tooling {
#[serde(rename = "mix_format")]
MixFormat,

#[doc = "https://nickel-lang.org"]
#[serde(rename = "nickel_format")]
NickelFormat,

#[doc = "https://github.com/nim-lang/nim"]
#[serde(rename = "nimpretty")]
Nimpretty,
Expand Down Expand Up @@ -911,6 +916,7 @@ impl Tooling {
Self::MdFormat => mdformat::run(snippet_path),
Self::Misspell => misspell::run(snippet_path),
Self::MixFormat => mix_format::run(snippet_path),
Self::NickelFormat => nickel::run_format(snippet_path),
Self::NicklockwoodSwiftFormat => swiftformat::run(snippet_path),
Self::Nimpretty => nimpretty::run(snippet_path),
Self::Nixfmt => nixfmt::run(snippet_path),
Expand Down Expand Up @@ -1058,6 +1064,7 @@ impl core::fmt::Display for Tooling {
Self::MdFormat => write!(f, "mdformat"),
Self::Misspell => write!(f, "misspell"),
Self::MixFormat => write!(f, "mix_format"),
Self::NickelFormat => write!(f, "nickel_format"),
Self::NicklockwoodSwiftFormat => write!(f, "swiftformat"),
Self::Nimpretty => write!(f, "nimpretty"),
Self::Nixfmt => write!(f, "nixfmt"),
Expand Down
11 changes: 11 additions & 0 deletions src/formatters/nickel.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use super::execute_command;
use crate::error::MdsfError;

#[inline]
pub fn run_format(file_path: &std::path::Path) -> Result<(bool, Option<String>), MdsfError> {
let mut cmd = std::process::Command::new("nickel");

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

execute_command(&mut cmd, file_path)
}

0 comments on commit 4883e31

Please sign in to comment.