Configuration files
1local ft_formatters = {
2 lua = { "stylua" },
3 cmake = { "gersemi" },
4 c = { "clang-format" },
5 cpp = { "clang-format" },
6 zig = { "zigfmt" },
7 toml = { "taplo" },
8 rust = { "rustfmt" },
9 odin = { "odinfmt" },
10}
11
12local formatters = {
13 odinfmt = {
14 command = "odinfmt",
15 args = { "-stdin" },
16 },
17}
18
19local ok, local_fmt = pcall(require, "local_fmt")
20if ok then
21 if local_fmt.ft_formatters ~= nil then
22 ft_formatters = vim.tbl_deep_extend("force", ft_formatters, local_fmt.ft_formatters)
23 end
24 if local_fmt.formatters ~= nil then
25 formatters = vim.tbl_deep_extend("force", formatters, local_fmt.formatters)
26 end
27else
28 vim.print("error loading local_fmt")
29end
30
31return {
32 "stevearc/conform.nvim",
33 lazy = true,
34 cmd = "ConformInfo",
35 event = "BufWritePre",
36 keys = {
37 {
38 "<leader>cf",
39 function()
40 require("conform").format({ async = true })
41 end,
42 desc = "Format buffer",
43 },
44 {
45 "<leader>cf",
46 function()
47 require("conform").format({ async = true })
48 end,
49 mode = { "x", "v" },
50 desc = "Format selection",
51 },
52 {
53 "<leader>ci",
54 "<cmd>ConformInfo<cr>",
55 desc = "Formatter info",
56 },
57 },
58 opts = {
59 notify_on_error = true,
60 formatters_by_ft = ft_formatters,
61 formatters = formatters,
62 },
63}