From 592cb247bf2ff3b46b9cdf5c3a9112da9c700ea4 Mon Sep 17 00:00:00 2001 From: Archit Gupta Date: Sat, 16 Sep 2023 20:59:54 -0700 Subject: [PATCH] Clarify use of formatter option The fact it uses bash is an implementation detail. Update the documentation to state that the input is a file name glob rather than a bash case match. Updates the default formatters to not rely on being a bash case statement. --- api_guide.md | 6 +++--- builtinModules/builtinFormatters.nix | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/api_guide.md b/api_guide.md index dc6f650..0607ff7 100644 --- a/api_guide.md +++ b/api_guide.md @@ -587,9 +587,9 @@ By default, `nix` files are formatted with `nixpkgs-fmt` and `md`, `json`, and To disable default formatters, set the `flakelight.builtinFormatters` option to false. -You can set `formatters` to an attribute set, for which the keys are a bash case -pattern and the value is the formatting command. `formatters` can optionally be -a function that takes packages and returns the above. +You can set `formatters` to an attribute set, for which the keys are a file name +pattern and the value is the corresponding formatting command. `formatters` can +optionally be a function that takes packages and returns the above. Formatting tools should be added to `devShell.packages` and all packages in `devShell.packages` will be available for formatting commands. diff --git a/builtinModules/builtinFormatters.nix b/builtinModules/builtinFormatters.nix index 4908e5f..1ab35ad 100644 --- a/builtinModules/builtinFormatters.nix +++ b/builtinModules/builtinFormatters.nix @@ -18,7 +18,9 @@ in formatters = { "*.nix" = "nixpkgs-fmt"; - "*.md | *.json | *.yml" = "prettier --write"; + "*.md" = "prettier --write"; + "*.json" = "prettier --write"; + "*.yml" = "prettier --write"; }; }; }