nvim: disable format on write by default
This commit is contained in:
parent
b3c8886304
commit
470543f295
1 changed files with 2 additions and 10 deletions
|
@ -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
|
||||
vim.notify("Format on write DISABLED", vim.log.levels.WARN)
|
||||
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
|
||||
vim.notify("Format on write enabled", vim.log.levels.INFO)
|
||||
end
|
||||
verbose = true -- Notify from second call on.
|
||||
end
|
||||
end)()
|
||||
|
||||
toggle_format_on_write() -- Enable by default.
|
||||
|
||||
return {
|
||||
"mhartington/formatter.nvim",
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue