mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-21 16:39:06 +02:00
perf(markdown): don't format with markdown-toc when no toc in the doc
This commit is contained in:
parent
b43ace1ecf
commit
73e72ee21d
1 changed files with 13 additions and 2 deletions
|
@ -14,9 +14,20 @@ return {
|
||||||
"stevearc/conform.nvim",
|
"stevearc/conform.nvim",
|
||||||
optional = true,
|
optional = true,
|
||||||
opts = {
|
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,
|
||||||
|
},
|
||||||
|
},
|
||||||
formatters_by_ft = {
|
formatters_by_ft = {
|
||||||
["markdown"] = { { "prettierd", "prettier" }, "markdownlint-cli2", "markdown-toc" },
|
["markdown"] = { "prettier", "markdownlint-cli2", "markdown-toc" },
|
||||||
["markdown.mdx"] = { { "prettierd", "prettier" }, "markdownlint-cli2", "markdown-toc" },
|
["markdown.mdx"] = { "prettier", "markdownlint-cli2", "markdown-toc" },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue