gabrielgio.lua @ 71e4c13d7345ccb6f6c0c371f40e9dcb6569ade0

 1local formatter = require("formatter")
 2local go = require("formatter.filetypes.go")
 3local util = require("formatter.util")
 4
 5formatter.setup({
 6	filetype = {
 7		nix = { require("formatter.filetypes.nix").alejandra },
 8		lua = { require("formatter.filetypes.lua").stylua },
 9		fish = { require("formatter.filetypes.fish").fishindent },
10		javascript = { require("formatter.filetypes.javascript").prettier },
11		go = { go.gofumpt, go.goimports },
12		terraform = {
13			function()
14				return {
15					exe = "terraform",
16					args = {
17						"fmt",
18						"-",
19					},
20					stdin = true,
21				}
22			end,
23		},
24		yaml = {
25			function()
26				return { exe = "yamlfmt" }
27			end,
28		},
29	},
30	["*"] = {
31		require("formatter.filetypes.any").remove_trailing_whitespace,
32	},
33})
34
35vim.api.nvim_create_augroup("__formatter__", { clear = true })
36vim.api.nvim_create_autocmd("BufWritePost", {
37	group = "__formatter__",
38	command = ":FormatWrite",
39})