use clang-format

This commit is contained in:
ant 2025-06-04 18:56:48 +02:00
parent 7dac9b74ee
commit 61b0ed3154

View file

@ -484,6 +484,11 @@ local plugins = {
uncrustify = { uncrustify = {
prepend_args = { "-c", "./scripts/uncrustify.cfg" }, prepend_args = { "-c", "./scripts/uncrustify.cfg" },
}, },
["clang-format"] = {
prepend_args = {
"--style", "file:" .. vim.fn.expand("~/clang-format.yaml")
},
}
}, },
formatters_by_ft = { formatters_by_ft = {
@ -503,6 +508,20 @@ local plugins = {
end end
require("conform").format({ async = true, lsp_format = "fallback", range = range }) require("conform").format({ async = true, lsp_format = "fallback", range = range })
end, { range = true }) end, { range = true })
-- vim.api.nvim_create_user_command("FormatClang", function(args)
-- local range = nil
-- if args.count ~= -1 then
-- local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1]
-- range = {
-- start = { args.line1, 0 },
-- ["end"] = { args.line2, end_line:len() },
-- }
-- end
-- require("conform").format({ formatters = { "clang-format" }, range = range })
-- end, { range = true })
--
-- vim.keymap.set({"v"}, "<leader>fl", ":FormatClang<cr>", { desc = "Format with clang"})
end end
}, },
{ {