mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-11-09 06:55:30 +00:00
languages: allow listOf format.type
This commit is contained in:
parent
266f5bc01f
commit
60004b0da2
24 changed files with 314 additions and 355 deletions
|
|
@ -8,7 +8,7 @@
|
|||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.meta) getExe;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.types) enum package bool;
|
||||
inherit (lib.types) enum bool;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
inherit (lib.nvim.types) diagnostics mkGrammarOption singleOrListOf;
|
||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||
|
|
@ -30,10 +30,10 @@
|
|||
};
|
||||
};
|
||||
|
||||
defaultFormat = "shfmt";
|
||||
defaultFormat = ["shfmt"];
|
||||
formats = {
|
||||
shfmt = {
|
||||
package = pkgs.shfmt;
|
||||
command = getExe pkgs.shfmt;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -68,16 +68,10 @@ in {
|
|||
description = "Enable Bash formatting";
|
||||
};
|
||||
type = mkOption {
|
||||
type = enum (attrNames formats);
|
||||
type = singleOrListOf (enum (attrNames formats));
|
||||
default = defaultFormat;
|
||||
description = "Bash formatter to use";
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = package;
|
||||
default = formats.${cfg.format.type}.package;
|
||||
description = "Bash formatter package";
|
||||
};
|
||||
};
|
||||
|
||||
extraDiagnostics = {
|
||||
|
|
@ -108,9 +102,14 @@ in {
|
|||
(mkIf cfg.format.enable {
|
||||
vim.formatter.conform-nvim = {
|
||||
enable = true;
|
||||
setupOpts.formatters_by_ft.sh = [cfg.format.type];
|
||||
setupOpts.formatters.${cfg.format.type} = {
|
||||
command = getExe cfg.format.package;
|
||||
setupOpts = {
|
||||
formatters_by_ft.sh = cfg.format.type;
|
||||
formatters =
|
||||
mapListToAttrs (name: {
|
||||
inherit name;
|
||||
value = formats.${name};
|
||||
})
|
||||
cfg.format.type;
|
||||
};
|
||||
};
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue