diff --git a/README.md b/README.md index c9a06a2..5952ed8 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,7 @@ EOF -- if set to `nil` then no specific condition is applied condition = nil, write_all_buffers = false, -- write all buffers when the current one meets `condition` + noautocmd = false, -- do not execute autocmds when saving debounce_delay = 1000, -- delay after which a pending save is executed -- log debug messages to 'auto-save.log' file in neovim cache directory, set to `true` to enable debug = false, diff --git a/lua/auto-save/config.lua b/lua/auto-save/config.lua index 07d3d80..ae5cbf8 100644 --- a/lua/auto-save/config.lua +++ b/lua/auto-save/config.lua @@ -23,6 +23,7 @@ Config = { --- @type nil|fun(buf: number): boolean condition = nil, write_all_buffers = false, -- write all buffers when the current one meets `condition` + noautocmd = false, -- do not execute autocmds when saving debounce_delay = 1000, -- delay after which a pending save is executed -- log debug messages to 'auto-save.log' file in neovim cache directory, set to `true` to enable debug = false, -- print debug messages, set to `true` to enable diff --git a/lua/auto-save/init.lua b/lua/auto-save/init.lua index 85113a6..032b002 100644 --- a/lua/auto-save/init.lua +++ b/lua/auto-save/init.lua @@ -81,11 +81,12 @@ local function save(buf) autocmds.exec_autocmd("AutoSaveWritePre", buf) + local noautocmd = cnf.opts.noautocmd and "noautocmd " or "" if cnf.opts.write_all_buffers then - cmd("silent! wall") + cmd(noautocmd .. "silent! wall") else api.nvim_buf_call(buf, function() - cmd("silent! write") + cmd(noautocmd .. "silent! write") end) end