-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathtextlint.nix
More file actions
97 lines (89 loc) · 2.3 KB
/
Copy pathtextlint.nix
File metadata and controls
97 lines (89 loc) · 2.3 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
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
{
config,
pkgs,
lib,
mkServerModule,
...
}:
let
cfg = config.programs.textlint;
finalPackage =
if cfg.extensions == [ ] then pkgs.textlint else pkgs.textlint.withPackages cfg.extensions;
configFile =
if cfg.configFile != null then
cfg.configFile
else if cfg.settings != { } then
pkgs.writeText ".textlintrc.json" (builtins.toJSON cfg.settings)
else
null;
in
{
imports = [
(mkServerModule {
name = "textlint";
packageName = "textlint";
})
];
options.programs.textlint = {
extensions = lib.mkOption {
type = with lib.types; listOf package;
default = [ ];
example = lib.literalExpression ''
[
pkgs.textlint-rule-alex
pkgs.textlint-plugin-org
pkgs.textlint-rule-preset-ja-technical-writing
]
'';
description = ''
List of textlint extension packages (rules, plugins, presets, filter-rules, configs).
These packages will be available via NODE_PATH.
'';
};
configFile = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
example = lib.literalExpression "./.textlintrc.json";
description = ''
Path to .textlintrc configuration file.
This file specifies which rules to enable and their settings.
Takes precedence over the settings option.
'';
};
settings = lib.mkOption {
type = lib.types.attrsOf lib.types.anything;
default = { };
example = lib.literalExpression ''
{
rules = {
alex = true;
terminology = {
defaultTerms = true;
};
};
}
'';
description = ''
Textlint configuration expressed as Nix attributes.
Will be converted to JSON and used as the configuration file.
Ignored if configFile is set.
'';
};
};
config = lib.mkIf cfg.enable {
assertions = [
{
assertion = cfg.configFile != null || cfg.settings != { };
message = "programs.textlint requires either configFile or settings to be set.";
}
];
programs.textlint.package = lib.mkDefault finalPackage;
settings.servers.textlint = {
args = [
"--mcp"
"--config"
(toString configFile)
];
};
};
}