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

45 lines
1012 B
Lua
Raw Permalink 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" },
c = { "clang-format" },
2024-05-24 16:07:28 +03:00
},
format_on_save = function(bufnr)
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
-- quiet = true,
return { timeout_ms = 500, lsp_fallback = true }
end,
2024-05-24 16:07:28 +03:00
},
init = function()
vim.o.formatexpr = "v:lua.require('conform').formatexpr()"
end,
},
}