Merge branch 'main' into main

This commit is contained in:
Nikita 2025-05-09 22:22:16 +03:00 committed by GitHub
commit b6486a2aba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
176 changed files with 4155 additions and 1832 deletions

View file

@ -5,12 +5,13 @@
...
}: let
inherit (builtins) attrNames;
inherit (lib.meta) getExe;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.lists) isList concatLists;
inherit (lib.types) bool enum either package listOf str;
inherit (lib.lists) isList;
inherit (lib.types) bool enum either package listOf str nullOr;
inherit (lib.nvim.lua) expToLua toLuaObject;
inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption;
inherit (lib.nvim.types) diagnostics mkGrammarOption mkPluginSetupOption;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.languages.markdown;
@ -32,31 +33,23 @@
};
};
defaultFormat = "denofmt";
defaultFormat = "deno_fmt";
formats = {
# for backwards compatibility
denofmt = {
package = pkgs.deno;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.deno_fmt.with({
filetypes = ${expToLua (concatLists [cfg.format.extraFiletypes ["markdown"]])},
command = "${cfg.format.package}/bin/deno",
})
)
'';
};
deno_fmt = {
package = pkgs.deno;
};
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",
})
)
'';
};
};
defaultDiagnosticsProvider = ["markdownlint-cli2"];
diagnosticsProviders = {
markdownlint-cli2 = {
package = pkgs.markdownlint-cli2;
};
};
in {
@ -74,7 +67,7 @@ in {
};
lsp = {
enable = mkEnableOption "Enable Markdown LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Enable Markdown LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
type = enum (attrNames servers);
@ -96,7 +89,7 @@ in {
type = mkOption {
type = enum (attrNames formats);
default = defaultFormat;
description = "Markdown formatter to use";
description = "Markdown formatter to use. `denofmt` is deprecated and currently aliased to deno_fmt.";
};
package = mkOption {
@ -121,15 +114,19 @@ in {
[render-markdown.nvim]: https://github.com/MeanderingProgrammer/render-markdown.nvim
Inline Markdown rendering with [render-markdown.nvim]
'';
};
setupOpts = mkPluginSetupOption "render-markdown" {
auto_override_publish_diagnostics = mkOption {
description = "Automatically override the publish_diagnostics handler";
type = bool;
default = true;
file_types = lib.mkOption {
type = nullOr (listOf str);
default = null;
description = ''
List of buffer filetypes to enable this plugin in.
This will cause the plugin to attach to new buffers who
have any of these filetypes.
'';
};
};
};
@ -146,6 +143,15 @@ in {
setupOpts = mkPluginSetupOption "markview-nvim" {};
};
};
extraDiagnostics = {
enable = mkEnableOption "extra Markdown diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
types = diagnostics {
langDesc = "Markdown";
inherit diagnosticsProviders;
inherit defaultDiagnosticsProvider;
};
};
};
config = mkIf cfg.enable (mkMerge [
@ -160,8 +166,17 @@ in {
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.markdown-format = formats.${cfg.format.type}.nullConfig;
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;
};
};
})
# Extensions
@ -178,5 +193,16 @@ in {
require("markview").setup(${toLuaObject cfg.extensions.markview-nvim.setupOpts})
'';
})
(mkIf cfg.extraDiagnostics.enable {
vim.diagnostics.nvim-lint = {
enable = true;
linters_by_ft.markdown = cfg.extraDiagnostics.types;
linters = mkMerge (map (name: {
${name}.cmd = getExe diagnosticsProviders.${name}.package;
})
cfg.extraDiagnostics.types);
};
})
]);
}