Skip to content

Commit f0764db

Browse files
MattSturgeonkhaneliman
authored andcommitted
plugins/efmls: add renames for HTML & JSON setup options
This required adding an internal `warnings` option to the submodule, and filtering out the aliases and the `warnings` option when iterating over the setup options.
1 parent bc21063 commit f0764db

File tree

2 files changed

+62
-15
lines changed

2 files changed

+62
-15
lines changed

plugins/by-name/efmls-configs/default.nix

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,24 @@ in
8686
}
8787
)
8888
) tools;
89+
90+
# Added 2025-06-25 in https://github.com/nix-community/nixvim/pull/3503
91+
imports =
92+
map (name: lib.mkRenamedOptionModule [ name ] [ (lib.toLower name) ]) [
93+
"HTML"
94+
"JSON"
95+
]
96+
++ lib.singleton {
97+
# NOTE: we need a warnings option for `mkRenamedOptionModule` to warn about unexpected definitions
98+
# This can be removed when all rename aliases are gone
99+
options.warnings = lib.mkOption {
100+
type = with lib.types; listOf str;
101+
description = "Warnings to propagate to nixvim's `warnings` option.";
102+
default = [ ];
103+
internal = true;
104+
visible = false;
105+
};
106+
};
89107
};
90108
description = "Configuration for each filetype. Use `all` to match any filetype.";
91109
default = { };
@@ -98,13 +116,24 @@ in
98116
# Tools that have been selected by the user
99117
tools = lib.lists.unique (
100118
lib.filter lib.isString (
101-
lib.concatMap (
102-
{
103-
linter ? [ ],
104-
formatter ? [ ],
105-
}:
106-
(lib.toList linter) ++ (lib.toList formatter)
107-
) (lib.attrValues cfg.setup)
119+
lib.concatMap
120+
(
121+
{
122+
linter ? [ ],
123+
formatter ? [ ],
124+
}:
125+
(lib.toList linter) ++ (lib.toList formatter)
126+
)
127+
(
128+
lib.attrValues (
129+
# Rename aliases added 2025-06-25 in https://github.com/nix-community/nixvim/pull/3503
130+
builtins.removeAttrs cfg.setup [
131+
"warnings"
132+
"HTML"
133+
"JSON"
134+
]
135+
)
136+
)
108137
)
109138
);
110139

@@ -131,14 +160,22 @@ in
131160
) (lib.toList opt);
132161

133162
setupOptions =
134-
(lib.mapAttrs (
135-
_:
136-
{
137-
linter ? [ ],
138-
formatter ? [ ],
139-
}:
140-
(mkToolValue "linters" linter) ++ (mkToolValue "formatters" formatter)
141-
) (lib.attrsets.filterAttrs (v: _: v != "all") cfg.setup))
163+
(lib.mapAttrs
164+
(
165+
_:
166+
{
167+
linter ? [ ],
168+
formatter ? [ ],
169+
}:
170+
(mkToolValue "linters" linter) ++ (mkToolValue "formatters" formatter)
171+
)
172+
(
173+
builtins.removeAttrs cfg.setup [
174+
"all"
175+
"warnings"
176+
]
177+
)
178+
)
142179
// {
143180
"=" =
144181
(mkToolValue "linters" cfg.setup.all.linter) ++ (mkToolValue "formatters" cfg.setup.all.formatter);
@@ -164,4 +201,9 @@ in
164201

165202
extraPackages = [ cfg.efmLangServerPackage ] ++ (map (v: cfg.toolPackages.${v}) nixvimPkgs.right);
166203
};
204+
205+
imports = lib.singleton {
206+
# Propagate setup warnings
207+
inherit (config.plugins.efmls-configs.setup) warnings;
208+
};
167209
}

tests/test-sources/plugins/by-name/efmls-configs/default.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
toolOptions = builtins.removeAttrs (setup.type.getSubOptions setup.loc) [
2121
"_freeformOptions"
2222
"_module"
23+
24+
# Rename aliases added 2025-06-25 in https://github.com/nix-community/nixvim/pull/3503
25+
"warnings"
26+
"HTML"
27+
"JSON"
2328
];
2429

2530
brokenTools =

0 commit comments

Comments
 (0)