neovim-dotfiles/lua/plugins/conformer.lua
2025-04-30 20:08:59 +02:00

50 lines
1.3 KiB
Lua

return {
"stevearc/conform.nvim",
event = { "BufWritePre" },
cmd = { "ConformInfo" },
init = function()
require "conform".setup(
{
format_on_save = function(bufnr)
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,
}