Skip to content
Open
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ functions.
<!-- `> bash ./supported-programs.sh` -->

<!-- BEGIN mdsh -->
`treefmt-nix` currently supports 120 formatters:
`treefmt-nix` currently supports 121 formatters:

* [actionlint](programs/actionlint.nix)
* [aiken](programs/aiken.nix)
Expand Down Expand Up @@ -340,6 +340,7 @@ functions.
* [typstyle](programs/typstyle.nix)
* [xmllint](programs/xmllint.nix)
* [yamlfmt](programs/yamlfmt.nix)
* [yamllint](programs/yamllint.nix)
* [yapf](programs/yapf.nix)
* [zig](programs/zig.nix)
* [zizmor](programs/zizmor.nix)
Expand Down
6 changes: 6 additions & 0 deletions examples/formatter-yamllint.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Example generated by ../examples.sh
[formatter.yamllint]
command = "yamllint"
excludes = []
includes = ["*.yaml", "*.yml"]
options = []
46 changes: 46 additions & 0 deletions programs/yamllint.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
lib,
pkgs,
config,
mkFormatterModule,
...
}:
let
cfg = config.programs.yamllint;
settingsFormat = pkgs.formats.yaml { };
in
{
meta.maintainers = [
"DigitalBrewStudios/Treefmt-nix"
];

imports = [
(mkFormatterModule {
name = "yamllint";
includes = [
"*.yaml"
"*.yml"
];
})
];

options.programs.yamllint = {
settings = lib.mkOption {
type = lib.types.submodule { freeformType = settingsFormat.type; };
default = { };
description = ''
Configuration for yamllint, see
<link xlink:href="https://yamllint.readthedocs.io/en/stable/configuration.html"/>
for supported values.
'';
};
};

config = lib.mkIf cfg.enable {
settings.formatter.yamllint = {
options = lib.optional (
cfg.settings != { }
) "-c=${settingsFormat.generate "yamllint.yaml" cfg.settings}";
};
};
}