diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index 8e3d93e0..1d3e0491 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -287,6 +287,7 @@ [venkyr77](https://github.com/venkyr77): - Add lint (luacheck) and formatting (stylua) support for Lua. +- Add lint (markdownlint-cli2) support for Markdown. [tebuevd](https://github.com/tebuevd): diff --git a/modules/plugins/languages/markdown.nix b/modules/plugins/languages/markdown.nix index 6767a9cf..2447aba0 100644 --- a/modules/plugins/languages/markdown.nix +++ b/modules/plugins/languages/markdown.nix @@ -11,7 +11,7 @@ inherit (lib.lists) isList; inherit (lib.types) bool enum either package listOf str; 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; @@ -46,6 +46,12 @@ package = pkgs.prettierd; }; }; + defaultDiagnosticsProvider = ["markdownlint-cli2"]; + diagnosticsProviders = { + markdownlint-cli2 = { + package = pkgs.markdownlint-cli2; + }; + }; in { options.vim.languages.markdown = { enable = mkEnableOption "Markdown markup language support"; @@ -121,6 +127,15 @@ in { }; }; }; + + extraDiagnostics = { + enable = mkEnableOption "extra Markdown diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;}; + types = diagnostics { + langDesc = "Markdown"; + inherit diagnosticsProviders; + inherit defaultDiagnosticsProvider; + }; + }; }; config = mkIf cfg.enable (mkMerge [ @@ -155,5 +170,16 @@ in { require("render-markdown").setup(${toLuaObject cfg.extensions.render-markdown-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); + }; + }) ]); }