mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-07 02:41:33 +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
|
@ -8,8 +8,8 @@
|
|||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.meta) getExe;
|
||||
inherit (lib.types) bool enum listOf package;
|
||||
inherit (lib.nvim.types) diagnostics mkGrammarOption;
|
||||
inherit (lib.types) bool enum listOf;
|
||||
inherit (lib.nvim.types) diagnostics mkGrammarOption singleOrListOf;
|
||||
inherit (lib.nvim.dag) entryBefore;
|
||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||
|
||||
|
@ -34,10 +34,10 @@
|
|||
};
|
||||
};
|
||||
|
||||
defaultFormat = "stylua";
|
||||
defaultFormat = ["stylua"];
|
||||
formats = {
|
||||
stylua = {
|
||||
package = pkgs.stylua;
|
||||
command = getExe pkgs.stylua;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -79,16 +79,10 @@ in {
|
|||
description = "Enable Lua formatting";
|
||||
};
|
||||
type = mkOption {
|
||||
type = enum (attrNames formats);
|
||||
type = singleOrListOf (enum (attrNames formats));
|
||||
default = defaultFormat;
|
||||
description = "Lua formatter to use";
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = package;
|
||||
default = formats.${cfg.format.type}.package;
|
||||
description = "Lua formatter package";
|
||||
};
|
||||
};
|
||||
|
||||
extraDiagnostics = {
|
||||
|
@ -132,10 +126,13 @@ in {
|
|||
(mkIf cfg.format.enable {
|
||||
vim.formatter.conform-nvim = {
|
||||
enable = true;
|
||||
setupOpts.formatters_by_ft.lua = [cfg.format.type];
|
||||
setupOpts.formatters.${cfg.format.type} = {
|
||||
command = getExe cfg.format.package;
|
||||
};
|
||||
setupOpts.formatters_by_ft.lua = 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