.dotfiles/.config/nvim/lua/nvwynd/plugins/formatting.lua

42 lines
870 B
Lua
Raw Normal View History

2024-05-24 16:07:28 +03:00
return {
{
"stevearc/conform.nvim",
event = { "BufWritePre" },
cmd = { "ConformInfo" },
keys = {
{
"<leader>fc",
function()
require("conform").format({ async = true, lsp_fallback = true })
end,
mode = "",
desc = "[F]ormat [C]ode inside current buffer",
},
},
opts = {
formatters_by_ft = {
lua = { "stylua" },
python = { "ruff_format" },
rust = { "rustfmt" },
html = { "prettier" },
htmldjango = { "prettier" },
css = { "prettier" },
json = { "prettier" },
scss = { "prettier" },
javascript = { "prettier" },
2024-05-24 16:07:28 +03:00
markdown = { "dprint" },
zig = { "zigfmt" },
toml = { "taplo" },
2024-05-24 16:07:28 +03:00
},
format_on_save = {
timeout_ms = 500,
lsp_fallback = true,
-- quiet = true,
2024-05-24 16:07:28 +03:00
},
},
init = function()
vim.o.formatexpr = "v:lua.require('conform').formatexpr()"
end,
},
}