fix(nvim): issue with conform formatting in JavaScript/TypeScript files

This commit is contained in:
Stefan Imhoff
2025-01-29 11:18:18 +01:00
parent 5d2bac92c6
commit 1d8df51599
2 changed files with 54 additions and 67 deletions

View File

@@ -18,57 +18,44 @@ return {
},
},
opts = {
formatters = {
["eslint_d"] = {
command = "eslint_d",
args = { "--fix-to-stdout", "--stdin", "--stdin-filename", "$FILENAME" },
stdin = true,
},
["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
-- 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,
},
["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,
},
["nixpkgs_fmt"] = {
command = "nixpkgs-fmt",
},
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,
},
formatters_by_ft = {
-- ["*"] = { "codespell" },
["_"] = { "trim_whitespace" },
["astro"] = { { "prettierd", "prettier" } },
["css"] = { { "prettierd", "prettier" }, "stylelint" },
["astro"] = { { "prettierd", "prettier", stop_after_first = true } },
["css"] = { { "prettierd", "prettier", stop_after_first = true }, "stylelint" },
["eruby"] = { "htmlbeautifier" },
["fish"] = { "fish_indent" },
["go"] = { "goimports", "gofumpt" },
["graphql"] = { { "prettierd", "prettier" } },
["html"] = { { "prettierd", "prettier" } },
["javascript"] = { { "prettierd", "prettier" }, "eslint_d" },
["javascriptreact"] = { { "prettierd", "prettier" }, "eslint_d" },
["json"] = { { "prettierd", "prettier" } },
["graphql"] = { { "prettierd", "prettier", stop_after_first = true } },
["html"] = { { "prettierd", "prettier", stop_after_first = true } },
["json"] = { { "prettierd", "prettier", stop_after_first = true } },
["lua"] = { "stylua" },
["markdown"] = { "prettierd", "prettier", "markdownlint-cli2", "markdown-toc" },
["markdown.mdx"] = { "prettierd", "prettier", "markdownlint-cli2", "markdown-toc" },
["mdx"] = { { "prettierd", "prettier" } },
["nix"] = { "nixpkgs_fmt" },
["mdx"] = { { "prettierd", "prettier", stop_after_first = true } },
["python"] = { "isort", "black" },
["ruby"] = { "rubyfmt", "rubocop" },
["svelte"] = { { "prettierd", "prettier" } },
["typescript"] = { { "prettierd", "prettier" }, "eslint_d" },
["typescriptreact"] = { { "prettierd", "prettier" }, "eslint_d" },
["yaml"] = { { "prettierd", "prettier" } },
["svelte"] = { { "prettierd", "prettier", stop_after_first = true } },
["yaml"] = { { "prettierd", "prettier", stop_after_first = true } },
},
},
}