1
0
Fork 0
forked from nya/nvim
nvim/lua/nyanko/lazy/conform.lua

48 lines
879 B
Lua
Raw Permalink Normal View History

2025-01-04 08:07:29 -06:00
return {
"stevearc/conform.nvim",
event = { "BufWritePre" },
cmd = { "ConformInfo" },
keys = {
{
"<leader>f",
function()
require("conform").format({
async = true,
lsp_format = "fallback",
})
end,
mode = "",
desc = "[F]ormat buffer",
},
},
opts = {
notify_on_error = false,
format_on_save = function(bufnr)
local disable_filetypes = {
c = true,
cpp = true,
}
local lsp_format_opt
if disable_filetypes[vim.bo[bufnr].filetype] then
lsp_format_opt = "never"
else
lsp_format_opt = "fallback"
end
return {
timeout_ms = 500,
lsp_format = lsp_format_opt,
}
end,
formatters_by_ft = {
lua = { "stylua" },
javascript = { "prettierd" },
javascriptreact = { "prettierd" },
typescript = { "prettierd" },
typescriptreact = { "prettierd" },
json = { "prettierd" },
},
},
}