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
2 changes: 2 additions & 0 deletions examples/formatter-oxfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ includes = [
"*.json5",
"*.jsonc",
"*.jsx",
"*.less",
"*.md",
"*.mdx",
"*.mjs",
"*.mustache",
"*.scss",
"*.toml",
"*.ts",
"*.tsx",
"*.vue",
Expand Down
28 changes: 27 additions & 1 deletion programs/oxfmt.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{ mkFormatterModule, ... }:
{
lib,
config,
mkFormatterModule,
...
}:
let
cfg = config.programs.oxfmt;
in
{
meta.maintainers = [ "jnsgruk" ];

Expand All @@ -16,11 +24,13 @@
"*.json5"
"*.jsonc"
"*.jsx"
"*.less"
"*.md"
"*.mdx"
"*.mjs"
"*.mustache"
"*.scss"
"*.toml"
"*.ts"
"*.tsx"
"*.vue"
Expand All @@ -29,4 +39,20 @@
];
})
];

options.programs.oxfmt = {
# See supported extensions: https://oxc.rs/docs/guide/usage/formatter/quickstart.html#pre-commit-with-lint-staged
allFiles = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Format all files by using a wildcard include pattern. Passes --no-error-on-unmatched-pattern so unsupported files are silently skipped.";
};
};

config = lib.mkIf (cfg.enable && cfg.allFiles) {
settings.formatter.oxfmt = {
includes = [ "*" ];
options = [ "--no-error-on-unmatched-pattern" ];
};
};
}