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
|
@ -59,19 +59,16 @@
|
|||
};
|
||||
};
|
||||
|
||||
defaultFormat = "gofmt";
|
||||
defaultFormat = ["gofmt"];
|
||||
formats = {
|
||||
gofmt = {
|
||||
package = pkgs.go;
|
||||
config.command = "${cfg.format.package}/bin/gofmt";
|
||||
command = "${pkgs.go}/bin/gofmt";
|
||||
};
|
||||
gofumpt = {
|
||||
package = pkgs.gofumpt;
|
||||
config.command = getExe cfg.format.package;
|
||||
command = getExe pkgs.gofumpt;
|
||||
};
|
||||
golines = {
|
||||
package = pkgs.golines;
|
||||
config.command = "${cfg.format.package}/bin/golines";
|
||||
command = "${pkgs.golines}/bin/golines";
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -113,15 +110,9 @@ in {
|
|||
|
||||
type = mkOption {
|
||||
description = "Go formatter to use";
|
||||
type = enum (attrNames formats);
|
||||
type = singleOrListOf (enum (attrNames formats));
|
||||
default = defaultFormat;
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "Go formatter package";
|
||||
type = package;
|
||||
default = formats.${cfg.format.type}.package;
|
||||
};
|
||||
};
|
||||
|
||||
dap = {
|
||||
|
@ -163,8 +154,13 @@ in {
|
|||
(mkIf cfg.format.enable {
|
||||
vim.formatter.conform-nvim = {
|
||||
enable = true;
|
||||
setupOpts.formatters_by_ft.go = [cfg.format.type];
|
||||
setupOpts.formatters.${cfg.format.type} = formats.${cfg.format.type}.config;
|
||||
setupOpts.formatters_by_ft.go = 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