perf(markdown): don't format with markdown-toc when no toc in the doc
This commit is contained in:
@ -14,9 +14,20 @@ return {
|
||||
"stevearc/conform.nvim",
|
||||
optional = true,
|
||||
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 = {
|
||||
["markdown"] = { { "prettierd", "prettier" }, "markdownlint-cli2", "markdown-toc" },
|
||||
["markdown.mdx"] = { { "prettierd", "prettier" }, "markdownlint-cli2", "markdown-toc" },
|
||||
["markdown"] = { "prettier", "markdownlint-cli2", "markdown-toc" },
|
||||
["markdown.mdx"] = { "prettier", "markdownlint-cli2", "markdown-toc" },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
Reference in New Issue
Block a user