feat: [#15] Implement config option for noautocmd (#31)

This commit is contained in:
Toni Müller
2023-07-21 08:32:24 +02:00
committed by GitHub
parent 2af4f275d7
commit c7427f4d78
3 changed files with 5 additions and 2 deletions

View File

@@ -112,6 +112,7 @@ EOF
-- if set to `nil` then no specific condition is applied -- if set to `nil` then no specific condition is applied
condition = nil, condition = nil,
write_all_buffers = false, -- write all buffers when the current one meets `condition` 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 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 -- log debug messages to 'auto-save.log' file in neovim cache directory, set to `true` to enable
debug = false, debug = false,

View File

@@ -23,6 +23,7 @@ Config = {
--- @type nil|fun(buf: number): boolean --- @type nil|fun(buf: number): boolean
condition = nil, condition = nil,
write_all_buffers = false, -- write all buffers when the current one meets `condition` 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 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 -- 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 debug = false, -- print debug messages, set to `true` to enable

View File

@@ -81,11 +81,12 @@ local function save(buf)
autocmds.exec_autocmd("AutoSaveWritePre", buf) autocmds.exec_autocmd("AutoSaveWritePre", buf)
local noautocmd = cnf.opts.noautocmd and "noautocmd " or ""
if cnf.opts.write_all_buffers then if cnf.opts.write_all_buffers then
cmd("silent! wall") cmd(noautocmd .. "silent! wall")
else else
api.nvim_buf_call(buf, function() api.nvim_buf_call(buf, function()
cmd("silent! write") cmd(noautocmd .. "silent! write")
end) end)
end end