mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 10:21:31 +00:00
languages: allow listOf format.type
This commit is contained in:
parent
a2b3010bb3
commit
70555904a0
22 changed files with 265 additions and 357 deletions
|
@ -9,7 +9,7 @@
|
|||
inherit (lib.meta) getExe;
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.types) enum package;
|
||||
inherit (lib.types) enum;
|
||||
inherit (lib.nvim.types) mkGrammarOption diagnostics singleOrListOf;
|
||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||
|
||||
|
@ -49,14 +49,14 @@
|
|||
};
|
||||
};
|
||||
|
||||
defaultFormat = "alejandra";
|
||||
defaultFormat = ["alejandra"];
|
||||
formats = {
|
||||
alejandra = {
|
||||
package = pkgs.alejandra;
|
||||
command = getExe pkgs.alejandra;
|
||||
};
|
||||
|
||||
nixfmt = {
|
||||
package = pkgs.nixfmt-rfc-style;
|
||||
command = getExe pkgs.nixfmt-rfc-style;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -109,15 +109,9 @@ in {
|
|||
|
||||
type = mkOption {
|
||||
description = "Nix formatter to use";
|
||||
type = enum (attrNames formats);
|
||||
type = singleOrListOf (enum (attrNames formats));
|
||||
default = defaultFormat;
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "Nix formatter package";
|
||||
type = package;
|
||||
default = formats.${cfg.format.type}.package;
|
||||
};
|
||||
};
|
||||
|
||||
extraDiagnostics = {
|
||||
|
@ -161,10 +155,13 @@ in {
|
|||
(mkIf (cfg.format.enable && !cfg.lsp.enable) {
|
||||
vim.formatter.conform-nvim = {
|
||||
enable = true;
|
||||
setupOpts.formatters_by_ft.nix = [cfg.format.type];
|
||||
setupOpts.formatters.${cfg.format.type} = {
|
||||
command = getExe cfg.format.package;
|
||||
};
|
||||
setupOpts.formatters_by_ft.nix = cfg.format.type;
|
||||
setupOpts.formatters =
|
||||
mapListToAttrs (name: {
|
||||
inherit name;
|
||||
value = formats.${name};
|
||||
})
|
||||
cfg.format.type;
|
||||
};
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue