From 61b0ed3154365c02f73a4075f3b04fd916849d7f Mon Sep 17 00:00:00 2001 From: ant Date: Wed, 4 Jun 2025 18:56:48 +0200 Subject: [PATCH] use clang-format --- lua/plugins.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lua/plugins.lua b/lua/plugins.lua index 04add89..dd82f38 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -484,6 +484,11 @@ local plugins = { uncrustify = { prepend_args = { "-c", "./scripts/uncrustify.cfg" }, }, + ["clang-format"] = { + prepend_args = { + "--style", "file:" .. vim.fn.expand("~/clang-format.yaml") + }, + } }, formatters_by_ft = { @@ -503,6 +508,20 @@ local plugins = { end require("conform").format({ async = true, lsp_format = "fallback", range = range }) 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"}, "fl", ":FormatClang", { desc = "Format with clang"}) end }, {