Files
lux/modules/capabilities/neovim/lua-config/lua/plugins/formatting.lua
T
2026-09-06 04:03:54 +02:00

48 lines
1.1 KiB
Lua

local formatters_by_ft = {
lua = { "stylua" },
nix = { "nixfmt" },
javascript = { "oxfmt" },
javascriptreact = { "oxfmt" },
typescript = { "oxfmt" },
typescriptreact = { "oxfmt" },
json = { "oxfmt" },
jsonc = { "oxfmt" },
css = { "oxfmt" },
html = { "oxfmt" },
svelte = { "oxfmt" },
astro = { lsp_format = "fallback" },
python = { "ruff_fix", "ruff_format" },
rust = { "rustfmt" },
toml = { "taplo" },
yaml = { "yamlfmt" },
typst = { "typstyle" },
}
require("lz.n").load({
{
"conform.nvim",
event = "BufWritePre",
cmd = "ConformInfo",
keys = {
{
"<leader>cf",
function()
require("conform").format({ async = true })
end,
mode = { "n", "x" },
desc = "Format selection or buffer",
},
},
after = function()
require("conform").setup({
formatters_by_ft = formatters_by_ft,
format_on_save = function(bufnr)
if formatters_by_ft[vim.bo[bufnr].filetype] then
return { timeout_ms = 500 }
end
end,
})
end,
},
})