dotfiles/nvim/lua/plugins/formatter.lua

34 lines
1 KiB
Lua
Raw Normal View History

2024-10-27 16:21:40 +00:00
return {
"stevearc/conform.nvim",
event = { "BufReadPre", "BufNewFile" },
config = function()
local conform = require("conform")
conform.setup({
formatters_by_ft = {
javascript = { "prettier" },
typescript = { "prettier" },
javascriptreact = { "prettier" },
typescriptreact = { "prettier" },
css = { "prettier" },
html = { "prettier" },
json = { "prettier" },
yaml = { "prettier" },
markdown = { "prettier" },
python = { "isort", "black" },
c = { "clang_format" },
},
formatters = {
clang_format = { args = { "--style=file" } },
},
format_on_save = {
lsp_format = "fallback",
async = false,
timeout_ms = 1000,
},
})
vim.keymap.set({ "n", "v" }, "<leader>f", function()
conform.format({ lsp_format = "fallback", async = false, timeout_ms = 1000 })
end, { desc = "Format file or range" })
end,
2024-10-27 16:21:40 +00:00
}