languages: allow listOf format.type

This commit is contained in:
Ching Pei Yang 2025-08-23 16:04:51 +02:00
commit 70555904a0
No known key found for this signature in database
GPG key ID: B3841364253DC4C8
22 changed files with 265 additions and 357 deletions

View file

@ -91,14 +91,14 @@
};
};
defaultFormat = "typstfmt";
defaultFormat = ["typstfmt"];
formats = {
typstfmt = {
package = pkgs.typstfmt;
command = getExe pkgs.typstfmt;
};
# https://github.com/Enter-tainer/typstyle
typstyle = {
package = pkgs.typstyle;
command = getExe pkgs.typstyle;
};
};
in {
@ -124,16 +124,10 @@ in {
enable = mkEnableOption "Typst document formatting" // {default = config.vim.languages.enableFormat;};
type = mkOption {
type = enum (attrNames formats);
type = singleOrListOf (enum (attrNames formats));
default = defaultFormat;
description = "Typst formatter to use";
};
package = mkOption {
type = package;
default = formats.${cfg.format.type}.package;
description = "Typst formatter package";
};
};
extensions = {
@ -189,10 +183,13 @@ in {
(mkIf cfg.format.enable {
vim.formatter.conform-nvim = {
enable = true;
setupOpts.formatters_by_ft.typst = [cfg.format.type];
setupOpts.formatters.${cfg.format.type} = {
command = getExe cfg.format.package;
};
setupOpts.formatters_by_ft.typst = cfg.format.type;
setupOpts.formatters =
mapListToAttrs (name: {
inherit name;
value = formats.${name};
})
cfg.format.type;
};
})