languages: allow listOf format.type

This commit is contained in:
Ching Pei Yang 2025-08-23 16:04:51 +02:00
commit 60004b0da2
No known key found for this signature in database
GPG key ID: B3841364253DC4C8
24 changed files with 314 additions and 355 deletions

View file

@ -6,7 +6,7 @@
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) package enum;
inherit (lib.types) enum;
inherit (lib.meta) getExe;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.generators) mkLuaInline;
@ -51,10 +51,10 @@
};
};
defaultFormat = "fantomas";
defaultFormat = ["fantomas"];
formats = {
fantomas = {
package = pkgs.fantomas;
command = getExe pkgs.fantomas;
};
};
@ -81,16 +81,10 @@ in {
enable = mkEnableOption "F# formatting" // {default = config.vim.languages.enableFormat;};
type = mkOption {
type = enum (attrNames formats);
type = singleOrListOf (enum (attrNames formats));
default = defaultFormat;
description = "F# formatter to use";
};
package = mkOption {
type = package;
default = formats.${cfg.format.type}.package;
description = "F# formatter package";
};
};
};
};
@ -113,9 +107,14 @@ in {
(mkIf cfg.format.enable {
vim.formatter.conform-nvim = {
enable = true;
setupOpts.formatters_by_ft.fsharp = [cfg.format.type];
setupOpts.formatters.${cfg.format.type} = {
command = getExe cfg.format.package;
setupOpts = {
formatters_by_ft.fsharp = cfg.format.type;
formatters =
mapListToAttrs (name: {
inherit name;
value = formats.${name};
})
cfg.format.type;
};
};
})