Skip to content

Commit

Permalink
Add options to 'typos' hook
Browse files Browse the repository at this point in the history
Also sort options alphabetically
  • Loading branch information
totoroot committed Aug 3, 2023
1 parent fcbf470 commit b9ce83a
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions modules/hooks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,11 @@ in
};
typos =
{
write =
color =
mkOption {
type = types.bool;
description = lib.mdDoc "Whether to write fixes out.";
default = false;
type = types.enum [ "auto" "always" "never" ];
description = lib.mdDoc "When to use generate output.";
default = "auto";
};

diff =
Expand All @@ -300,12 +300,41 @@ in
default = false;
};

exclude =
mkOption {
type = types.str;
description = lib.mdDoc "Which files & directories to exclude matching the glob.";
default = "";
example = "*.nix";
};

format =
mkOption {
type = types.enum [ "silent" "brief" "long" "json" ];
description = lib.mdDoc "Output format.";
description = lib.mdDoc "Which output format to use.";
default = "long";
};

hidden =
mkOption {
type = types.bool;
description = lib.mdDoc "Whether to search hidden files and directories.";
default = false;
};

locale =
mkOption {
type = types.enum [ "en" "en-us" "en-gb" "en-ca" "en-au" ];
description = lib.mdDoc "Which language to use for spell checking.";
default = "en";
};

write =
mkOption {
type = types.bool;
description = lib.mdDoc "Whether to write fixes out.";
default = false;
};
};

revive =
Expand Down Expand Up @@ -1195,7 +1224,7 @@ in
name = "typos";
description = "Source code spell checker";
entry = with settings.typos;
"${tools.typos}/bin/typos --format ${format} ${lib.optionalString write "-w"} ${lib.optionalString diff "--diff"}";
"${tools.typos}/bin/typos --color ${color} ${lib.optionalString diff "--diff"} --exclude ${exclude} --format ${format} {lib.optionalString hidden " - -hidden "} --locale ${locale} ${lib.optionalString write "-write-changes"}";
types = [ "text" ];
};

Expand Down

0 comments on commit b9ce83a

Please sign in to comment.