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,7 +8,7 @@
|
|||
inherit (lib.meta) getExe;
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.types) bool enum package;
|
||||
inherit (lib.types) bool enum;
|
||||
inherit (lib.lists) optional;
|
||||
inherit (lib.nvim.types) mkGrammarOption diagnostics singleOrListOf;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
|
@ -25,14 +25,11 @@
|
|||
};
|
||||
};
|
||||
|
||||
defaultFormat = "superhtml";
|
||||
defaultFormat = ["superhtml"];
|
||||
formats = {
|
||||
superhtml = {
|
||||
package = pkgs.writeShellApplication {
|
||||
name = "superhtml_fmt";
|
||||
runtimeInputs = [pkgs.superhtml];
|
||||
text = "superhtml fmt -";
|
||||
};
|
||||
command = "${pkgs.superhtml}/bin/superhtml";
|
||||
args = ["fmt" "-"];
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -68,16 +65,10 @@ in {
|
|||
enable = mkEnableOption "HTML formatting" // {default = config.vim.languages.enableFormat;};
|
||||
|
||||
type = mkOption {
|
||||
type = enum (attrNames formats);
|
||||
type = singleOrListOf (enum (attrNames formats));
|
||||
default = defaultFormat;
|
||||
description = "HTML formatter to use";
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = package;
|
||||
default = formats.${cfg.format.type}.package;
|
||||
description = "HTML formatter package";
|
||||
};
|
||||
};
|
||||
|
||||
extraDiagnostics = {
|
||||
|
@ -119,10 +110,13 @@ in {
|
|||
(mkIf (cfg.format.enable && !cfg.lsp.enable) {
|
||||
vim.formatter.conform-nvim = {
|
||||
enable = true;
|
||||
setupOpts.formatters_by_ft.html = [cfg.format.type];
|
||||
setupOpts.formatters.${cfg.format.type} = {
|
||||
command = getExe cfg.format.package;
|
||||
};
|
||||
setupOpts.formatters_by_ft.html = 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