Skip to main content

Markdown

info

You can enable the extra with the :LazyExtras command. Plugins marked as optional will only be configured if they are installed.

Alternatively, you can add it to your lazy.nvim imports
lua/config/lazy.lua
require("lazy").setup({
spec = {
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
{ import = "lazyvim.plugins.extras.lang.markdown" },
{ import = "plugins" },
},
})

Below you can find a list of included plugins and their default settings.

caution

You don't need to copy the default settings to your config. They are only shown here for reference.

mason.nvim

opts = { ensure_installed = { "markdownlint-cli2", "markdown-toc" } }

nvim-lspconfig

opts = {
servers = {
marksman = {},
},
}

markdown-preview.nvim

Markdown preview

opts = {}

markdown.nvim

opts = {
file_types = { "markdown", "norg", "rmd", "org" },
code = {
sign = false,
width = "block",
right_pad = 1,
},
heading = {
sign = false,
icons = {},
},
}

conform.nvim (optional)

opts = {
formatters = {
["markdown-toc"] = {
condition = function(_, ctx)
for _, line in ipairs(vim.api.nvim_buf_get_lines(ctx.buf, 0, -1, false)) do
if line:find("<!%-%- toc %-%->") then
return true
end
end
end,
},
["markdownlint-cli2"] = {
condition = function(_, ctx)
local diag = vim.tbl_filter(function(d)
return d.source == "markdownlint"
end, vim.diagnostic.get(ctx.buf))
return #diag > 0
end,
},
},
formatters_by_ft = {
["markdown"] = { "prettier", "markdownlint-cli2", "markdown-toc" },
["markdown.mdx"] = { "prettier", "markdownlint-cli2", "markdown-toc" },
},
}

none-ls.nvim (optional)

opts = function(_, opts)
local nls = require("null-ls")
opts.sources = vim.list_extend(opts.sources or {}, {
nls.builtins.diagnostics.markdownlint_cli2,
})
end

nvim-lint (optional)

opts = {
linters_by_ft = {
markdown = { "markdownlint-cli2" },
},
}