languages/formatters: allow multiple formatters (#1103)

* language/python: allow multiple formatters

* package: add prettier-plugin-astro

* language/astro: fix prettier, remove prettierd

* package: add prettier-plugin-svelte

* language/svelte: fix prettier, remove prettierd

* languages: allow listOf format.type

* deprecations: add warnings for removed format options

* ruby: remove unused variable

* nix: fix outdated references to format.package

* docs: update release note

* treewide: warn deprecation in singleOrListOf

* conform: add definitions for setupOpts.formatters
This commit is contained in:
Ching Pei Yang 2025-11-16 19:49:21 +01:00 committed by GitHub
commit d5da1a14c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
47 changed files with 641 additions and 488 deletions

View file

@ -11,16 +11,17 @@
inherit (lib.lists) isList;
inherit (lib.attrsets) attrNames;
inherit (lib.types) bool package str listOf either enum;
inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption;
inherit (lib.nvim.lua) expToLua toLuaObject;
inherit (lib.nvim.attrsets) mapListToAttrs;
inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption deprecatedSingleOrListOf;
inherit (lib.nvim.dag) entryAfter entryAnywhere;
cfg = config.vim.languages.rust;
defaultFormat = "rustfmt";
defaultFormat = ["rustfmt"];
formats = {
rustfmt = {
package = pkgs.rustfmt;
command = getExe pkgs.rustfmt;
};
};
in {
@ -69,15 +70,9 @@ in {
type = mkOption {
description = "Rust formatter to use";
type = enum (attrNames formats);
type = deprecatedSingleOrListOf "vim.language.rust.format.type" (enum (attrNames formats));
default = defaultFormat;
};
package = mkOption {
description = "Rust formatter package";
type = package;
default = formats.${cfg.format.type}.package;
};
};
dap = {
@ -127,9 +122,14 @@ in {
(mkIf cfg.format.enable {
vim.formatter.conform-nvim = {
enable = true;
setupOpts.formatters_by_ft.rust = [cfg.format.type];
setupOpts.formatters.${cfg.format.type} = {
command = getExe cfg.format.package;
setupOpts = {
formatters_by_ft.rust = cfg.format.type;
formatters =
mapListToAttrs (name: {
inherit name;
value = formats.${name};
})
cfg.format.type;
};
};
})