plugins/efmls: add renames for HTML & JSON setup options
Some checks failed
Publish every Git push to main to FlakeHub / flakehub-publish (push) Has been cancelled
Publish every git push to Flakestry / publish-flake (push) Has been cancelled
Documentation / Version info (push) Has been cancelled
Documentation / Build (push) Has been cancelled
Documentation / Combine builds (push) Has been cancelled
Documentation / Deploy (push) Has been cancelled

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.
This commit is contained in:
Matt Sturgeon 2025-06-25 11:29:50 +01:00 committed by Austin Horstman
parent bc210635f4
commit f0764db721
2 changed files with 62 additions and 15 deletions

View file

@ -86,6 +86,24 @@ in
} }
) )
) tools; ) tools;
# Added 2025-06-25 in https://github.com/nix-community/nixvim/pull/3503
imports =
map (name: lib.mkRenamedOptionModule [ name ] [ (lib.toLower name) ]) [
"HTML"
"JSON"
]
++ lib.singleton {
# NOTE: we need a warnings option for `mkRenamedOptionModule` to warn about unexpected definitions
# This can be removed when all rename aliases are gone
options.warnings = lib.mkOption {
type = with lib.types; listOf str;
description = "Warnings to propagate to nixvim's `warnings` option.";
default = [ ];
internal = true;
visible = false;
};
};
}; };
description = "Configuration for each filetype. Use `all` to match any filetype."; description = "Configuration for each filetype. Use `all` to match any filetype.";
default = { }; default = { };
@ -98,13 +116,24 @@ in
# Tools that have been selected by the user # Tools that have been selected by the user
tools = lib.lists.unique ( tools = lib.lists.unique (
lib.filter lib.isString ( lib.filter lib.isString (
lib.concatMap ( lib.concatMap
(
{ {
linter ? [ ], linter ? [ ],
formatter ? [ ], formatter ? [ ],
}: }:
(lib.toList linter) ++ (lib.toList formatter) (lib.toList linter) ++ (lib.toList formatter)
) (lib.attrValues cfg.setup) )
(
lib.attrValues (
# Rename aliases added 2025-06-25 in https://github.com/nix-community/nixvim/pull/3503
builtins.removeAttrs cfg.setup [
"warnings"
"HTML"
"JSON"
]
)
)
) )
); );
@ -131,14 +160,22 @@ in
) (lib.toList opt); ) (lib.toList opt);
setupOptions = setupOptions =
(lib.mapAttrs ( (lib.mapAttrs
(
_: _:
{ {
linter ? [ ], linter ? [ ],
formatter ? [ ], formatter ? [ ],
}: }:
(mkToolValue "linters" linter) ++ (mkToolValue "formatters" formatter) (mkToolValue "linters" linter) ++ (mkToolValue "formatters" formatter)
) (lib.attrsets.filterAttrs (v: _: v != "all") cfg.setup)) )
(
builtins.removeAttrs cfg.setup [
"all"
"warnings"
]
)
)
// { // {
"=" = "=" =
(mkToolValue "linters" cfg.setup.all.linter) ++ (mkToolValue "formatters" cfg.setup.all.formatter); (mkToolValue "linters" cfg.setup.all.linter) ++ (mkToolValue "formatters" cfg.setup.all.formatter);
@ -164,4 +201,9 @@ in
extraPackages = [ cfg.efmLangServerPackage ] ++ (map (v: cfg.toolPackages.${v}) nixvimPkgs.right); extraPackages = [ cfg.efmLangServerPackage ] ++ (map (v: cfg.toolPackages.${v}) nixvimPkgs.right);
}; };
imports = lib.singleton {
# Propagate setup warnings
inherit (config.plugins.efmls-configs.setup) warnings;
};
} }

View file

@ -20,6 +20,11 @@
toolOptions = builtins.removeAttrs (setup.type.getSubOptions setup.loc) [ toolOptions = builtins.removeAttrs (setup.type.getSubOptions setup.loc) [
"_freeformOptions" "_freeformOptions"
"_module" "_module"
# Rename aliases added 2025-06-25 in https://github.com/nix-community/nixvim/pull/3503
"warnings"
"HTML"
"JSON"
]; ];
brokenTools = brokenTools =