Files
lux/modules/capabilities/neovim/lua-config/lua/plugins/formatting.lua
T
2026-07-08 15:04:16 +02:00

58 lines
1.5 KiB
Lua

require("lz.n").load({
{
"conform.nvim",
event = "BufWritePre",
cmd = "ConformInfo",
keys = {
{
"<leader>f",
function()
require("conform").format({ async = true, lsp_format = "fallback" })
end,
mode = "",
desc = "[F]ormat buffer",
},
},
after = function()
local prettier = { "prettierd", "prettier", stop_after_first = true }
require("conform").setup({
notify_on_error = true,
format_on_save = function(bufnr)
local disable_filetypes = { c = true, cpp = true }
if disable_filetypes[vim.bo[bufnr].filetype] then
return nil
else
return {
timeout_ms = 500,
lsp_format = "fallback",
}
end
end,
formatters_by_ft = {
javascript = prettier,
javascriptreact = prettier,
typescript = prettier,
typescriptreact = prettier,
json = prettier,
jsonc = prettier,
css = prettier,
scss = prettier,
less = prettier,
html = prettier,
markdown = prettier,
lua = { "stylua" },
python = { "ruff_fix", "ruff_format", "ruff_organize_imports" },
toml = { "taplo" },
yaml = { "yamlfmt" },
},
formatters = {
stylua = {
prepend_args = { "--indent-type", "Spaces", "--indent-width", "2" },
},
},
})
end,
},
})