fix(nvim): issue with conform

This commit is contained in:
Stefan Imhoff
2025-02-04 20:19:06 +01:00
parent 962964a54c
commit fc76e5afd1
2 changed files with 47 additions and 44 deletions

View File

@@ -18,44 +18,47 @@ return {
},
},
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
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
end,
stop_after_first = true,
},
["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,
stop_after_first = true,
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 = {
["_"] = { "trim_whitespace" },
["astro"] = { { "prettierd", "prettier", stop_after_first = true } },
["css"] = { { "prettierd", "prettier", stop_after_first = true }, "stylelint" },
["astro"] = { "prettierd", "prettier" },
["css"] = { "prettierd", "prettier", "stylelint" },
["eruby"] = { "htmlbeautifier" },
["fish"] = { "fish_indent" },
["go"] = { "goimports", "gofumpt" },
["graphql"] = { { "prettierd", "prettier", stop_after_first = true } },
["html"] = { { "prettierd", "prettier", stop_after_first = true } },
["json"] = { { "prettierd", "prettier", stop_after_first = true } },
["graphql"] = { "prettierd", "prettier" },
["html"] = { "prettierd", "prettier" },
["json"] = { "prettierd", "prettier" },
["lua"] = { "stylua" },
["markdown"] = { "prettierd", "prettier", "markdownlint-cli2", "markdown-toc" },
["markdown.mdx"] = { "prettierd", "prettier", "markdownlint-cli2", "markdown-toc" },
["mdx"] = { { "prettierd", "prettier", stop_after_first = true } },
["mdx"] = { "prettierd", "prettier" },
["python"] = { "isort", "black" },
["ruby"] = { "rubyfmt", "rubocop" },
["svelte"] = { { "prettierd", "prettier", stop_after_first = true } },
["yaml"] = { { "prettierd", "prettier", stop_after_first = true } },
["svelte"] = { "prettierd", "prettier" },
["yaml"] = { "prettierd", "prettier" },
},
-- If you want to use the stop_after_first behavior, add it at the root level
options = {
stop_after_first = true, -- This will apply globally
},
},
}