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
|
@ -4,11 +4,11 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) attrNames;
|
||||
inherit (builtins) attrNames warn;
|
||||
inherit (lib.meta) getExe;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.types) bool enum package listOf str nullOr;
|
||||
inherit (lib.types) bool enum listOf str nullOr;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.nvim.types) diagnostics mkGrammarOption mkPluginSetupOption singleOrListOf;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
|
@ -25,17 +25,17 @@
|
|||
};
|
||||
};
|
||||
|
||||
defaultFormat = "deno_fmt";
|
||||
defaultFormat = ["deno_fmt"];
|
||||
formats = {
|
||||
# for backwards compatibility
|
||||
denofmt = {
|
||||
package = pkgs.deno;
|
||||
command = getExe pkgs.deno;
|
||||
};
|
||||
deno_fmt = {
|
||||
package = pkgs.deno;
|
||||
command = getExe pkgs.deno;
|
||||
};
|
||||
prettierd = {
|
||||
package = pkgs.prettierd;
|
||||
command = getExe pkgs.prettierd;
|
||||
};
|
||||
};
|
||||
defaultDiagnosticsProvider = ["markdownlint-cli2"];
|
||||
|
@ -72,17 +72,11 @@ in {
|
|||
enable = mkEnableOption "Markdown formatting" // {default = config.vim.languages.enableFormat;};
|
||||
|
||||
type = mkOption {
|
||||
type = enum (attrNames formats);
|
||||
type = singleOrListOf (enum (attrNames formats));
|
||||
default = defaultFormat;
|
||||
description = "Markdown formatter to use. `denofmt` is deprecated and currently aliased to deno_fmt.";
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = package;
|
||||
default = formats.${cfg.format.type}.package;
|
||||
description = "Markdown formatter package";
|
||||
};
|
||||
|
||||
extraFiletypes = mkOption {
|
||||
type = listOf str;
|
||||
default = [];
|
||||
|
@ -157,14 +151,22 @@ in {
|
|||
(mkIf cfg.format.enable {
|
||||
vim.formatter.conform-nvim = {
|
||||
enable = true;
|
||||
setupOpts.formatters_by_ft.markdown = [cfg.format.type];
|
||||
setupOpts.formatters.${
|
||||
if cfg.format.type == "denofmt"
|
||||
then "deno_fmt"
|
||||
else cfg.format.type
|
||||
} = {
|
||||
command = getExe cfg.format.package;
|
||||
};
|
||||
setupOpts.formatters_by_ft.markdown = cfg.format.type;
|
||||
setupOpts.formatters = let
|
||||
names = map (name:
|
||||
if name == "denofmt"
|
||||
then
|
||||
warn ''
|
||||
vim.languages.markdown.format.type: "denofmt" is renamed to "deno_fmt".
|
||||
'' "deno_fmt"
|
||||
else name)
|
||||
cfg.format.type;
|
||||
in
|
||||
mapListToAttrs (name: {
|
||||
inherit name;
|
||||
value = formats.${name};
|
||||
})
|
||||
names;
|
||||
};
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue