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 toggle_format_on_write = (function()
|
||||||
local augroup_id = nil
|
local augroup_id = nil
|
||||||
local verbose = false -- Don't notify on first call.
|
|
||||||
return function()
|
return function()
|
||||||
if augroup_id then
|
if augroup_id then
|
||||||
vim.api.nvim_del_augroup_by_id(augroup_id)
|
vim.api.nvim_del_augroup_by_id(augroup_id)
|
||||||
augroup_id = nil
|
augroup_id = nil
|
||||||
if verbose then
|
|
||||||
vim.notify("Format on write DISABLED", vim.log.levels.WARN)
|
vim.notify("Format on write DISABLED", vim.log.levels.WARN)
|
||||||
end
|
|
||||||
else
|
else
|
||||||
augroup_id = vim.api.nvim_create_augroup("fschauen.format_on_write", { clear = true })
|
augroup_id = vim.api.nvim_create_augroup("fschauen.format_on_write", { clear = true })
|
||||||
vim.api.nvim_create_autocmd("BufWritePost", {
|
vim.api.nvim_create_autocmd("BufWritePost", {
|
||||||
|
@ -39,16 +36,11 @@ local toggle_format_on_write = (function()
|
||||||
pattern = "*",
|
pattern = "*",
|
||||||
command = ":FormatWrite",
|
command = ":FormatWrite",
|
||||||
})
|
})
|
||||||
if verbose then
|
|
||||||
vim.notify("Format on write enabled", vim.log.levels.INFO)
|
vim.notify("Format on write enabled", vim.log.levels.INFO)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
verbose = true -- Notify from second call on.
|
|
||||||
end
|
|
||||||
end)()
|
end)()
|
||||||
|
|
||||||
toggle_format_on_write() -- Enable by default.
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"mhartington/formatter.nvim",
|
"mhartington/formatter.nvim",
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue