-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy pathtypos.nix
153 lines (136 loc) · 3.82 KB
/
typos.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
{
lib,
config,
mkFormatterModule,
...
}:
let
cfg = config.programs.typos;
in
{
meta.maintainers = [ "adam-gaia" ];
imports = [
(mkFormatterModule {
name = "typos";
args = [ "--write-changes" ];
includes = [ "*" ];
})
];
options.programs.typos = {
threads = lib.mkOption {
type = lib.types.nullOr lib.types.int;
default = null;
example = 2;
description = "The approximate number of threads to use [default: 0]";
};
sort = lib.mkOption {
type = lib.types.bool;
default = false;
example = true;
description = "Sort results";
};
configFile = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
example = "typos.toml";
description = "Custom config file";
};
isolated = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Ignore implicit configuration files";
};
hidden = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Search hidden files and directories";
};
noIgnore = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Don't respect ignore files";
};
noIgnoreDot = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Don't respect .ignore files";
};
noIgnoreGlobal = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Don't respect global ignore files";
};
noIgnoreParent = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Don't respect ignore files in parent directories";
};
noIgnoreVCS = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Don't respect ignore files in vsc directories";
};
binary = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Search binary files";
};
noCheckFilenames = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Skip verifying spelling in file names";
};
noCheckFiles = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Skip verifying spelling in files";
};
noUnicode = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Only allow ASCII characters in identifiers";
};
locale = lib.mkOption {
type = lib.types.nullOr (
lib.types.enum [
"en"
"en-us"
"en-gb"
"en-ca"
"en-au"
]
);
default = null;
description = "Language locale to suggest corrections for [possible values: en, en-us, en-gb, en-ca, en-au]";
};
};
config = lib.mkIf cfg.enable {
settings.formatter.typos = {
options =
(lib.optionals (!isNull cfg.threads) [
"--threads"
(toString cfg.threads)
])
++ (lib.optionals (!isNull cfg.locale) [
"--locale"
(toString cfg.locale)
])
++ (lib.optionals (!isNull cfg.configFile) [
"--config"
cfg.configFile
])
++ lib.optional cfg.sort "--sort"
++ lib.optional cfg.isolated "--isolated"
++ lib.optional cfg.hidden "--hidden"
++ lib.optional cfg.noIgnore "--no-ignore"
++ lib.optional cfg.noIgnoreDot "--no-ignore-dot"
++ lib.optional cfg.noIgnoreGlobal "--no-ignore-global"
++ lib.optional cfg.noIgnoreParent "--no-ignore-parent"
++ lib.optional cfg.noIgnoreVCS "--no-ignore-vcs"
++ lib.optional cfg.binary "--binary"
++ lib.optional cfg.noCheckFilenames "--no-check-filenames"
++ lib.optional cfg.noCheckFiles "--no-check-files"
++ lib.optional cfg.noUnicode "--no-unicode";
};
};
}