neovim-dotfiles/lua/plugins/conformer.lua
2025-12-23 22:46:35 +01:00

53 lines
1.5 KiB
Lua

return {
"stevearc/conform.nvim",
dependencies = { "frostplexx/mason-bridge.nvim" },
event = { "BufWritePre" },
cmd = { "ConformInfo" },
init = function()
require("conform").setup({
format_on_save = function(bufnr)
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
require("conform").formatters_by_ft = require("mason-bridge").get_formatters()
return { timeout_ms = 200, lsp_fallback = true }, on_format
end,
formatters_by_ft = require("mason-bridge").get_formatters(), --[[ = {
lua = { "stylua" },
javascript = { "prettier" },
html = { "prettier" },
css = { "prettier" },
c = { "clang-format" },
cpp = { "clang-format" },
arduino = { "clang-format" },
sh = { "shfmt" },
bash = { "shfmt" },
mksh = { "shfmt" },
json = { "jq" },
}, ]] --
-- This will provide type hinting with LuaLS
---@module "conform"
---@type conform.setupOpts
formatters = {
prettier = {
prepend_args = { "--use-tabs", "true" },
},
jq = {
prepend_args = { "--tab" },
},
["clang-format"] = {
prepend_args = function(self, ctx)
return { "-style=file:/home/Dario48/.config/.clang-format" }
end,
},
default_format_opts = {
lsp_format = "fallback",
},
},
})
-- If you want the formatexpr, here is the place to set it
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
vim.g.arduino_recommended_style = 0
end,
}