nvim: disable format on write by default

This commit is contained in:
Fernando Schauenburg 2024-07-20 00:34:00 +02:00
parent b3c8886304
commit 470543f295

View file

@ -23,14 +23,11 @@ end
local toggle_format_on_write = (function()
local augroup_id = nil
local verbose = false -- Don't notify on first call.
return function()
if augroup_id then
vim.api.nvim_del_augroup_by_id(augroup_id)
augroup_id = nil
if verbose then
vim.notify("Format on write DISABLED", vim.log.levels.WARN)
end
else
augroup_id = vim.api.nvim_create_augroup("fschauen.format_on_write", { clear = true })
vim.api.nvim_create_autocmd("BufWritePost", {
@ -39,16 +36,11 @@ local toggle_format_on_write = (function()
pattern = "*",
command = ":FormatWrite",
})
if verbose then
vim.notify("Format on write enabled", vim.log.levels.INFO)
end
end
verbose = true -- Notify from second call on.
end
end)()
toggle_format_on_write() -- Enable by default.
return {
"mhartington/formatter.nvim",