summaryrefslogtreecommitdiff
path: root/lua/config/packages/conform.lua
blob: af59b42a4157e33ea128a39ac95a05dd04df52ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
vim.pack.add({ gh("stevearc/conform.nvim") })

require("conform").setup({
    default_format_opts = { lsp_format = "fallback", async = true },
    formatters_by_ft = { 
        rust = { "rustfmt" },
        lua = { "stylua" }, 
        markdown = { "prettier" },
        makefile = { "bake" },
        c = { "clang-format" },
        cpp = { "clang-format" },
        bash = { "beautysh" }
    },
})
vim.keymap.set({ "n", "x" }, "<leader>lf", function() require("conform").format() end, { desc = "conform format" })

vim.api.nvim_create_autocmd("BufWritePre", {
  pattern = "*",
  callback = function(args)
    require("conform").format({ bufnr = args.buf })
  end,
})