33 lines
1.1 KiB
Lua
33 lines
1.1 KiB
Lua
-- ============================================================================
|
|
-- 自动格式化 (conform.nvim)
|
|
-- 保存时自动格式化,手动 <leader>cf 触发
|
|
-- ============================================================================
|
|
|
|
return {
|
|
{
|
|
"stevearc/conform.nvim",
|
|
event = { "BufWritePre" },
|
|
cmd = { "ConformInfo" },
|
|
keys = {
|
|
{ "<leader>cf", function() require("conform").format({ async = true }) end, desc = "格式化" },
|
|
},
|
|
opts = {
|
|
format_on_save = {
|
|
timeout_ms = 500,
|
|
lsp_fallback = true,
|
|
},
|
|
formatters_by_ft = {
|
|
rust = { "rustfmt" },
|
|
lua = { "stylua" },
|
|
c = { "clang-format" },
|
|
cpp = { "clang-format" },
|
|
},
|
|
formatters = {
|
|
["clang-format"] = {
|
|
args = { "--style={BasedOnStyle: LLVM, IndentWidth: 4, TabWidth: 4, UseTab: Never, ColumnLimit: 0}" },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|