treewide: apply linter suggestions

This commit is contained in:
Gaetan Lepage 2025-12-26 15:06:14 +01:00 committed by Austin Horstman
parent aca6fcdaff
commit 1d333fc92e
39 changed files with 54 additions and 59 deletions

View file

@ -19,7 +19,7 @@ let
|> builtins.attrValues
|> builtins.filter (entry: entry.variant or null == "primary")
|> builtins.filter (entry: builtins.elem entry.status supported)
|> builtins.map (entry: {
|> map (entry: {
name = entry.channel |> builtins.match "nixos-(.+)" |> builtins.head;
value = {
inherit (entry) channel status;

View file

@ -6,7 +6,7 @@
docsUrl ? "https://nix-community.github.io/nixvim/",
}:
src:
runCommand (src.name or (builtins.baseNameOf src))
runCommand (src.name or (baseNameOf src))
{
inherit src;
bindings =

View file

@ -25,10 +25,10 @@ let
builtins.concatMap (
node:
let
children = builtins.removeAttrs node [ "_page" ];
children = removeAttrs node [ "_page" ];
in
lib.optional (node ? _page) node._page ++ lib.optionals (children != { }) (collectPages children)
) (builtins.attrValues (builtins.removeAttrs pages [ "_category" ]));
) (builtins.attrValues (removeAttrs pages [ "_category" ]));
# Normalised page specs
pageList = collectPages pages;

View file

@ -65,7 +65,7 @@ let
value =
let
file = removeNixvimPrefix location.file;
line = builtins.toString location.line;
line = toString location.line;
text = "${file}:${line}";
target = "${urlPrefix}/${file}#L${line}";
in
@ -80,6 +80,6 @@ lib.pipe functionSet [
# No need to include out-of-tree entries
(builtins.filter (entry: lib.strings.hasPrefix rootPathString entry.location.file))
# Convert entries to attrset
(builtins.map entryToNameValuePair)
(map entryToNameValuePair)
builtins.listToAttrs
]

View file

@ -37,7 +37,7 @@ let
# whether to nest into a sub-page, so that we can keep the original
# _freeformOptions attr as intended.
attrs._freeformOptions or { }
// builtins.removeAttrs attrs [
// removeAttrs attrs [
"_module"
"_freeformOptions"
"warnings"
@ -96,7 +96,7 @@ let
let
info = lib.attrByPath path { } nixvimInfo;
maintainers = lib.unique (configuration.config.meta.maintainers.${info.file} or [ ]);
maintainersNames = builtins.map maintToMD maintainers;
maintainersNames = map maintToMD maintainers;
maintToMD = m: if m ? github then "[${m.name}](https://github.com/${m.github})" else m.name;
in
# Make sure this path has a valid info attrset
@ -304,7 +304,7 @@ let
# Attrset of { filePath = renderedDocs; }
platformOptionsFiles = lib.listToAttrs (
builtins.map (
map (
{ path, file, ... }:
{
name = path;

View file

@ -12,7 +12,7 @@ let
modules = [ ./page.nix ];
};
pages = builtins.removeAttrs config (builtins.attrNames options);
pages = removeAttrs config (builtins.attrNames options);
in
{
freeformType = lib.types.attrsOf pageType;

View file

@ -9,7 +9,7 @@ let
modules = [ ./category.nix ];
};
categories = builtins.removeAttrs config (builtins.attrNames options);
categories = removeAttrs config (builtins.attrNames options);
in
{
freeformType = lib.types.attrsOf categoryType;

View file

@ -20,7 +20,7 @@ let
nextPrefix = if showInMenu then loc else prefix;
nextIndent = if showInMenu && nested then indent + " " else indent;
children = builtins.removeAttrs page optionNames;
children = removeAttrs page optionNames;
submenu = lib.pipe children [
builtins.attrValues
(map (

View file

@ -5,7 +5,7 @@
drv, # The derivation under test
}:
let
toFile = name: v: if lib.isPath v then v else writeText name v;
mkFile = name: v: if lib.isPath v then v else writeText name v;
overrideSrc =
src:
@ -21,8 +21,8 @@ let
}:
testers.testEqualContents {
assertion = message;
actual = overrideSrc (toFile "${message}-input" input);
expected = toFile "${message}-expected" expected;
actual = overrideSrc (mkFile "${message}-input" input);
expected = mkFile "${message}-expected" expected;
};
in
# TODO: introduce some negative cases for input that should fail

View file

@ -103,7 +103,7 @@ You could use the builtin [`map`] function (or similar) to do something like thi
```nix
{
keymaps =
(builtins.map (key: {
(map (key: {
inherit key;
action = "<some-action>";
options.desc = "My cool keymapping";

View file

@ -1,7 +1,6 @@
{ lib, config, ... }:
let
inherit (lib)
mapAttrs
types
;
in
@ -39,7 +38,7 @@ in
# Transpose per-system definitions to the top-level
config.ci = {
buildbot = mapAttrs (_: sysCfg: sysCfg.ci.buildbot) config.allSystems;
buildbot = builtins.mapAttrs (_: sysCfg: sysCfg.ci.buildbot) config.allSystems;
};
};
}

View file

@ -65,7 +65,7 @@ rec {
# to ensure `lua` isn't evaluated when (e.g.) generating lua code.
# Failure to do so will result in "option used but not defined" errors!
deprecatedMapOptionSubmodule = mkMapOptionSubmodule { lua = true; };
removeDeprecatedMapAttrs = v: builtins.removeAttrs v [ "lua" ];
removeDeprecatedMapAttrs = v: removeAttrs v [ "lua" ];
mkModeOption =
default:

View file

@ -138,7 +138,7 @@
};
in
lib.pipe depsToEnable [
(builtins.map enableDepConditionally)
(map enableDepConditionally)
lib.listToAttrs
];
};

View file

@ -140,7 +140,6 @@ rec {
pluginLuaConfig = types.submodule (
{ config, ... }:
let
inherit (builtins) toString;
inherit (lib.nixvim.utils) mkBeforeSection mkAfterSection;
in
{

View file

@ -138,7 +138,7 @@ rec {
message = "${prefix} ${lib.trim a.message}";
};
in
builtins.map processAssertion (lib.toList assertions);
map processAssertion (lib.toList assertions);
/**
Convert one or several conditional warnings to a final warning list.

View file

@ -97,7 +97,7 @@ in
extraPackages = lib.pipe cfg [
builtins.attrValues
(builtins.filter (p: p.enable))
(builtins.map (p: p.package))
(map (p: p.package))
];
__depPackages = {

View file

@ -70,7 +70,7 @@ in
# NOTE: barbar added `mapOptionSubmodule` support shortly _before_ branching off 24.05
(lib.mapAttrsToList (name: opt: opt.valueMeta) (
builtins.removeAttrs options.plugins.barbar.keymaps [ "silent" ]
removeAttrs options.plugins.barbar.keymaps [ "silent" ]
))
]
[

View file

@ -20,7 +20,7 @@ let
{
_module.args = lib.pipe options._module.args [
lib.modules.mergeAttrDefinitionsWithPrio
(lib.flip builtins.removeAttrs [ "name" ])
(lib.flip removeAttrs [ "name" ])
(lib.mapAttrs (_: { highestPrio, value }: lib.mkOverride highestPrio value))
];
}

View file

@ -29,7 +29,7 @@ lib.fix (self: {
defaultPlugin // (if p ? plugin then p else { plugin = p; });
# Normalize a list of plugins
normalizePlugins = builtins.map self.normalizePlugin;
normalizePlugins = map self.normalizePlugin;
getAndNormalizeDeps = p: self.normalizePlugins (p.plugin.dependencies or [ ]);

View file

@ -21,9 +21,9 @@ let
};
go =
path: name: opt:
optPath: name: opt:
let
loc = path ++ lib.singleton name;
loc = optPath ++ lib.singleton name;
in
if lib.isOption opt then mkAlias loc opt else lib.mapAttrs (go loc) opt;
in

View file

@ -301,8 +301,8 @@ in
name:
lib.pipe cfg.${name} [
(builtins.filter (x: !x.predicate input.${name}))
(builtins.map (x: x.message))
(builtins.map (msg: if lib.isFunction msg then msg input.${name} else msg))
(map (x: x.message))
(map (msg: if lib.isFunction msg then msg input.${name} else msg))
(
x:
if x == [ ] then

View file

@ -186,7 +186,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
(listOf strLua)
)
);
apply = builtins.map mapToRawLua;
apply = map mapToRawLua;
default = [ ];
example = [
[

View file

@ -152,7 +152,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
(
lib.attrValues (
# Rename aliases added 2025-06-25 in https://github.com/nix-community/nixvim/pull/3503
builtins.removeAttrs cfg.languages [
removeAttrs cfg.languages [
"warnings"
"HTML"
"JSON"
@ -208,7 +208,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
(mkToolValue "linters" linter) ++ (mkToolValue "formatters" formatter)
)
(
builtins.removeAttrs cfg.languages [
removeAttrs cfg.languages [
"all"
# Rename aliases added 2025-06-25 in https://github.com/nix-community/nixvim/pull/3503
"warnings"

View file

@ -19,9 +19,11 @@ lib.nixvim.plugins.mkVimPlugin {
"plugins.blink-cmp.enable"
"plugins.nvim-snippets.enable"
];
enabledConsumers = builtins.filter (path: lib.getAttrFromPath path config) snippetConsumers;
enabledConsumers = builtins.filter (
consumerPath: lib.getAttrFromPath consumerPath config
) snippetConsumers;
enabledConsumersPretty = lib.concatMapStringsSep ", " (
path: lib.getAttrFromPath path options
consumerPath: lib.getAttrFromPath consumerPath options
) enabledConsumers;
in
{

View file

@ -86,7 +86,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
if builtins.isString p then
p
else
builtins.removeAttrs p [
removeAttrs p [
"path"
"requires"
]

View file

@ -6,7 +6,6 @@
}:
let
opts = options.plugins.rainbow-delimiters;
inherit (builtins) any isNull;
inherit (lib) mapAttrs' nameValuePair isString;
inherit (lib.nixvim) mkRaw toLuaObject nestedLiteralLua;
in
@ -103,7 +102,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
];
assertions = lib.nixvim.mkAssertions "plugins.rainbow-delimiters" {
assertion = any isNull [
assertion = builtins.any isNull [
(cfg.settings.whitelist or null)
(cfg.settings.blacklist or null)
];

View file

@ -223,7 +223,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
renamedSettings = lib.foldl' (
acc: optPath:
let
snakeCasePath = builtins.map lib.nixvim.toSnakeCase optPath;
snakeCasePath = map lib.nixvim.toSnakeCase optPath;
optValue = lib.getAttrFromPath optPath cfg.settings;
in
lib.recursiveUpdate acc (lib.setAttrByPath snakeCasePath optValue)

View file

@ -15,7 +15,7 @@
...
}@args:
lib.nixvim.plugins.mkVimPlugin (
builtins.removeAttrs args [
removeAttrs args [
"pluginName"
"sourceName"
]

View file

@ -174,7 +174,7 @@ let
mkCmpSourcePlugin = import ./_mk-cmp-plugin.nix {
inherit lib pkgs;
};
pluginModules = builtins.map mkCmpSourcePlugin sources;
pluginModules = map mkCmpSourcePlugin sources;
in
{
# For extra cmp plugins

View file

@ -82,7 +82,7 @@ in
acc: scope: renamed':
acc ++ lib.mapAttrsToList (old: new: lib.mkRenamedOptionModule [ scope old ] [ scope new ]) renamed'
) [ ] renamed
++ builtins.map (
++ map (
name:
lib.mkRemovedOptionModule [ "plugins" name "iconsPackage" ] ''
Please use `plugins.web-devicons` or `plugins.mini.modules.icons` with `plugins.mini.mockDevIcons`, or `plugins.mini-icons` with `plugins.mini-icons.mockDevIcons` instead.

View file

@ -163,7 +163,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
actionStr = action.action or action;
mode = action.mode or "n";
actionProps = lib.optionalAttrs (builtins.isAttrs action) (
builtins.removeAttrs action [
removeAttrs action [
"action"
"mode"
]

View file

@ -169,7 +169,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
in
[ (mkEntryFromDrv plugin) ] ++ processDependencies;
processedPlugins = builtins.concatLists (builtins.map processPlugin cfg.plugins);
processedPlugins = builtins.concatLists (map processPlugin cfg.plugins);
lazyPath = pkgs.linkFarm "lazy-plugins" processedPlugins;
pluginToLua =

View file

@ -27,7 +27,7 @@ let
# Recurse into all directories, extracting files as we find them.
# This returns a list of { name; file; cases; } attrsets.
fetchTests =
path: namespace:
testPath: namespace:
let
# Handle an entry from readDir
# - If it is a regular nix file, import its content
@ -35,7 +35,7 @@ let
handleEntry =
name: type:
let
file = /${path}/${name};
file = /${testPath}/${name};
in
if type == "regular" then
lib.optional (lib.hasSuffix ".nix" name) (
@ -46,7 +46,7 @@ let
else
fetchTests file (namespace ++ [ name ]);
in
lib.pipe path [
lib.pipe testPath [
builtins.readDir
(lib.filterAttrs (n: v: v != "symlink"))
(lib.mapAttrsToList handleEntry)

View file

@ -29,7 +29,7 @@ let
let
missingFromPkgs = builtins.concatMap (
loc: lib.optional (!lib.hasAttrByPath loc pkgs) (lib.concatStringsSep "." loc)
) (builtins.map lib.toList packages);
) (map lib.toList packages);
undeclared = lib.filter (name: !(lib.elem name declared)) generated;
uselesslyDeclared = lib.partition (name: lib.elem name unsupported) (
lib.filter (name: !(lib.elem name generated)) declared

View file

@ -564,7 +564,7 @@ else
runCommandLocal "lib-tests-failure"
{
results = lib.concatStringsSep "\n" (
builtins.map (result: ''
map (result: ''
${result.name}:
expected: ${lib.generators.toPretty { } result.expected}
result: ${lib.generators.toPretty { } result.result}

View file

@ -45,7 +45,7 @@ let
configuration.config.build.test.overrideAttrs (old: {
passthru =
old.passthru or { }
// builtins.removeAttrs configuration [
// removeAttrs configuration [
"_type"
"type"
]
@ -66,7 +66,7 @@ let
config = import ../example.nix { inherit pkgs; };
in
{
main = builtins.removeAttrs config.programs.nixvim [
main = removeAttrs config.programs.nixvim [
# This is not available to standalone modules, only HM & NixOS Modules
"enable"
# This is purely an example, it does not reflect a real usage

View file

@ -1,14 +1,12 @@
{
lib,
nixpkgsLib,
runCommandLocal,
}:
let
inherit (lib) attrNames filter length;
nixvimList = import ../lib/maintainers.nix;
nixpkgsList = nixpkgsLib.maintainers;
duplicates = filter (name: nixpkgsList ? ${name}) (attrNames nixvimList);
count = length duplicates;
duplicates = builtins.filter (name: nixpkgsList ? ${name}) (builtins.attrNames nixvimList);
count = builtins.length duplicates;
in
runCommandLocal "maintainers-test" { inherit count duplicates; } ''
if [ $count -gt 0 ]; then

View file

@ -11,7 +11,7 @@
# toolOptions is an attrsets of the form:
# { <lang> = { linter = tools; formatter = tools; }; }
# Where tools is the option type representing the valid tools for this language
toolOptions = builtins.removeAttrs (languages.type.getSubOptions languages.loc) [
toolOptions = removeAttrs (languages.type.getSubOptions languages.loc) [
"_freeformOptions"
"_module"

View file

@ -19,8 +19,6 @@
}:
let
inherit (lib)
listToAttrs
map
mkIf
mkMerge
optionalAttrs
@ -89,7 +87,7 @@ in
(optionalAttrs (filesOpt != null) (
mkIf (cfg.enable && !cfg.wrapRc) (
setAttrByPath filesOpt (
listToAttrs (
builtins.listToAttrs (
map (
{ target, finalSource, ... }:
{