From 01e948f6bef8e5b6a06a683f80396a1d33061af4 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 17 Apr 2024 12:19:12 +0800 Subject: [PATCH] feat(format): add c format --- bundle/format.nvim/lua/format/ft/c.lua | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 bundle/format.nvim/lua/format/ft/c.lua diff --git a/bundle/format.nvim/lua/format/ft/c.lua b/bundle/format.nvim/lua/format/ft/c.lua new file mode 100644 index 000000000..23eb8c109 --- /dev/null +++ b/bundle/format.nvim/lua/format/ft/c.lua @@ -0,0 +1,31 @@ +local M = {} + +function M.enabled() + return { 'uncrustify', 'clangformat', 'astyle' } +end + +function M.clangformat(opt) + return { + exe = 'clang-format', + args = { '-assume-filename=' .. opt.filepath }, + stdin = true, + } +end + +function M.uncrustify(opt) + return { + exe = 'uncrustify', + args = { '-q', '-l', 'C' }, + stdin = true, + } +end + +function M.astyle(opt) + return { + exe = 'astyle', + args = {'--mode=c'}, + stdin = true + } +end + +return M