初始化dotfiles
This commit is contained in:
32
nvim/lua/plugins/conform.lua
Normal file
32
nvim/lua/plugins/conform.lua
Normal file
@ -0,0 +1,32 @@
|
||||
-- ============================================================================
|
||||
-- 自动格式化 (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}" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user