mhartington/formatter.nvim

Multiple formatters on an empty file results in `v:null` in the file

Closed this issue · 4 comments

shreve commented

Which configuration?
Type (custom or builtin): builtin
Filetype: Any
Formatter: Any + formatter.filetypes.any.remove_trailing_whitespace

Configuration(s) (post all the variants you tried):

require("formatter").setup({
	filetype = {
		python = {
			require("formatter.filetypes.python").black,
		},
		lua = {
			require("formatter.filetypes.lua").stylua,
		},
		["*"] = {
			require("formatter.filetypes.any").remove_trailing_whitespace,
		},
	},
})

vim.api.nvim_create_autocmd("BufWritePost", { command = "FormatWriteLock" })

Expected behavior

When saving an empty file, the file would remain empty.

Actual behaviour

When saving an empty file, the text v:null is inserted before save. This occurred for both python and lua files.

xfzv commented

Same here.

Met the same issue. I think it is a bug.

ruzv commented

I have encountered this too

shreve commented

Fixed in #285