forked from numtide/treefmt-nix
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypstyle.nix
More file actions
57 lines (53 loc) · 1.15 KB
/
Copy pathtypstyle.nix
File metadata and controls
57 lines (53 loc) · 1.15 KB
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
{
lib,
config,
mkFormatterModule,
...
}:
let
cfg = config.programs.typstyle;
in
{
meta.maintainers = [ "SigmaSquadron" ];
imports = [
(mkFormatterModule {
name = "typstyle";
args = [ "-i" ];
includes = [
"*.typ"
"*.typst"
];
})
];
options.programs.typstyle = with lib; {
indentWidth = mkOption {
type = types.nullOr types.int;
default = null;
example = 4;
description = ''
Number of spaces per indent level (default: 2).
'';
};
lineWidth = mkOption {
type = types.nullOr types.int;
default = null;
example = 100;
description = ''
Maximum line width in characters (default: 80).
'';
};
wrapText = mkEnableOption "line wrapping of markup text";
};
config = lib.mkIf cfg.enable {
settings.formatter.typstyle.options =
lib.optional cfg.wrapText "--wrap-text"
++ lib.optionals (!isNull cfg.lineWidth) [
"--line-width"
(toString cfg.lineWidth)
]
++ lib.optionals (!isNull cfg.indentWidth) [
"--indent-width"
(toString cfg.indentWidth)
];
};
}