35 lines
774 B
Lua
35 lines
774 B
Lua
local conform = require("conform")
|
|
|
|
conform.setup({
|
|
formatters_by_ft = {
|
|
c = { "clang_format" },
|
|
cpp = { "clang_format" },
|
|
h = { "clang_format" },
|
|
hpp = { "clang_format" },
|
|
},
|
|
format_on_save = function(bufnr)
|
|
local ft = vim.bo[bufnr].filetype
|
|
local cpp_filetypes = {
|
|
c = true,
|
|
cpp = true,
|
|
h = true,
|
|
hpp = true,
|
|
}
|
|
|
|
if cpp_filetypes[ft] then
|
|
return {
|
|
timeout_ms = 1000,
|
|
lsp_format = "fallback",
|
|
}
|
|
end
|
|
end,
|
|
})
|
|
|
|
vim.api.nvim_create_user_command("Format", function()
|
|
conform.format({
|
|
async = false,
|
|
timeout_ms = 1000,
|
|
lsp_format = "fallback",
|
|
})
|
|
end, {})
|