gabrielgio.lua @ 5086b1d4be9afd6c6f9a25507a0bee612c889301

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