49 lines
1.1 KiB
Lua
49 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()
|
|
local conform = require("conform")
|
|
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,
|
|
},
|
|
})
|