aboutsummaryrefslogtreecommitdiff
path: root/lua/gabrielgio/formatter.lua
blob: d06a400610dee1c678112f9b9820fedbacdf49f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
local formatter = require("formatter")
local go = require("formatter.filetypes.go")

formatter.setup({
	filetype = {
		nix = { require("formatter.filetypes.nix").alejandra },
		lua = { require("formatter.filetypes.lua").stylua },
		fish = { require("formatter.filetypes.fish").fishindent },
		javascript = { require("formatter.filetypes.javascript").prettier },
		go = { go.gofumpt, go.goimports },
	},
	["*"] = {
		require("formatter.filetypes.any").remove_trailing_whitespace,
	},
})

vim.api.nvim_create_augroup("__formatter__", { clear = true })
vim.api.nvim_create_autocmd("BufWritePost", {
	group = "__formatter__",
	command = ":FormatWrite",
})