language/markdown: migrate to conform/nvim-lint

This commit is contained in:
Ching Pei Yang 2025-03-27 20:13:07 +01:00
parent 543deb5c2a
commit ab5dbb263e
No known key found for this signature in database
GPG key ID: B3841364253DC4C8

View file

@ -5,9 +5,10 @@
... ...
}: let }: let
inherit (builtins) attrNames; inherit (builtins) attrNames;
inherit (lib.meta) getExe;
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.lists) isList concatLists; inherit (lib.lists) isList;
inherit (lib.types) bool enum either package listOf str; inherit (lib.types) bool enum either package listOf str;
inherit (lib.nvim.lua) expToLua toLuaObject; inherit (lib.nvim.lua) expToLua toLuaObject;
inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption; inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption;
@ -32,31 +33,17 @@
}; };
}; };
defaultFormat = "denofmt"; defaultFormat = "deno_fmt";
formats = { formats = {
# for backwards compatibility
denofmt = { denofmt = {
package = pkgs.deno; package = pkgs.deno;
nullConfig = '' };
table.insert( deno_fmt = {
ls_sources, package = pkgs.deno;
null_ls.builtins.formatting.deno_fmt.with({
filetypes = ${expToLua (concatLists [cfg.format.extraFiletypes ["markdown"]])},
command = "${cfg.format.package}/bin/deno",
})
)
'';
}; };
prettierd = { prettierd = {
package = pkgs.prettierd; package = pkgs.prettierd;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.prettierd.with({
filetypes = ${expToLua (concatLists [cfg.format.extraFiletypes ["markdown"]])},
command = "${cfg.format.package}/bin/prettierd",
})
)
'';
}; };
}; };
in { in {
@ -96,7 +83,7 @@ in {
type = mkOption { type = mkOption {
type = enum (attrNames formats); type = enum (attrNames formats);
default = defaultFormat; default = defaultFormat;
description = "Markdown formatter to use"; description = "Markdown formatter to use. `denofmt` is deprecated and currently aliased to deno_fmt.";
}; };
package = mkOption { package = mkOption {
@ -148,8 +135,17 @@ in {
}) })
(mkIf cfg.format.enable { (mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true; vim.formatter.conform-nvim = {
vim.lsp.null-ls.sources.markdown-format = formats.${cfg.format.type}.nullConfig; 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;
};
};
}) })
# Extensions # Extensions