summaryrefslogtreecommitdiff
path: root/conform.lua
blob: 65a50e9e715b7ab22f871af9a02aa59faa1b22d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
return {
	"stevearc/conform.nvim",
	-- event = { "BufReadPre", "BufNewFile" }, -- Load when you open a file
	config = function()
		local conform = require("conform")

		conform.setup({
			formatters_by_ft = {
				-- Assign formatters to specific filetypes
				python = { "isort", "black" },
				tex = { "tex-fmt" },
				lua = { "stylua" },
				sh = { "shfmt" },
				json = { "json_repair" },
			},

			-- Override the default isort configuration
			formatters = {
				isort = {
					-- Remove the --filename argument and just use the file path
					args = { "--stdout", "-" },
				},
			},

			format_on_save = {
				lsp_fallback = true, -- Use LSP if no dedicated formatter is found
				async = false, -- Formatting must be synchronous to save correctly
				timeout_ms = 1000, -- Don't hang the UI for more than 0.5s
			},
		})
	end,
}