Skip to content

Commit

Permalink
fix(config): immediately save before quitting or suspending (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
zoriya authored Jan 7, 2025
1 parent b589484 commit d158bb0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ EOF
{
enabled = true, -- start auto-save when the plugin is loaded (i.e. when your package manager loads it)
trigger_events = { -- See :h events
immediate_save = { "BufLeave", "FocusLost" }, -- vim events that trigger an immediate save
immediate_save = { "BufLeave", "FocusLost", "QuitPre", "VimSuspend" }, -- vim events that trigger an immediate save
defer_save = { "InsertLeave", "TextChanged" }, -- vim events that trigger a deferred save (saves after `debounce_delay`)
cancel_deferred_save = { "InsertEnter" }, -- vim events that cancel a pending deferred save
},
Expand Down
12 changes: 6 additions & 6 deletions doc/auto-save.nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ VIM-PLUG *auto-save.nvim-installation-vim-plug*
{
enabled = true, -- start auto-save when the plugin is loaded (i.e. when your package manager loads it)
trigger_events = { -- See :h events
immediate_save = { "BufLeave", "FocusLost" }, -- vim events that trigger an immediate save
immediate_save = { "BufLeave", "FocusLost", "QuitPre", "VimSuspend" }, -- vim events that trigger an immediate save
defer_save = { "InsertLeave", "TextChanged" }, -- vim events that trigger a deferred save (saves after `debounce_delay`)
cancel_deferred_save = { "InsertEnter" }, -- vim events that cancel a pending deferred save
},
Expand Down Expand Up @@ -145,7 +145,7 @@ Here is an example that disables auto-save for specified file types:
{
condition = function(buf)
local filetype = vim.fn.getbufvar(buf, "&filetype")

-- don't save for `sql` file types
if vim.list_contains({ "sql" }, filetype) then
return false
Expand Down Expand Up @@ -217,7 +217,7 @@ An example to print a message with the file name after a file got saved:

>lua
local group = vim.api.nvim_create_augroup('autosave', {})

vim.api.nvim_create_autocmd('User', {
pattern = 'AutoSaveWritePost',
group = group,
Expand All @@ -234,15 +234,15 @@ Another example to print a message when enabling/disabling autosave:

>lua
local group = vim.api.nvim_create_augroup('autosave', {})

vim.api.nvim_create_autocmd('User', {
pattern = 'AutoSaveEnable',
group = group,
callback = function(opts)
vim.notify('AutoSave enabled', vim.log.levels.INFO)
end,
})

vim.api.nvim_create_autocmd('User', {
pattern = 'AutoSaveDisable',
group = group,
Expand Down Expand Up @@ -273,7 +273,7 @@ work on the original <https://github.com/Pocco81/auto-save.nvim>.
==============================================================================
9. Links *auto-save.nvim-links*

1. *@commitlint/config-conventional*:
1. *@commitlint/config-conventional*:

Generated by panvimdoc <https://github.com/kdheepak/panvimdoc>

Expand Down
2 changes: 1 addition & 1 deletion lua/auto-save/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Config = {
enabled = true, -- start auto-save when the plugin is loaded (i.e. when your package manager loads it)
trigger_events = { -- See :h events
--- @type TriggerEvent[]?
immediate_save = { "BufLeave", "FocusLost" }, -- vim events that trigger an immediate save
immediate_save = { "BufLeave", "FocusLost", "QuitPre", "VimSuspend" }, -- vim events that trigger an immediate save
--- @type TriggerEvent[]?
defer_save = { "InsertLeave", "TextChanged" }, -- vim events that trigger a deferred save (saves after `debounce_delay`)
--- @type TriggerEvent[]?
Expand Down

0 comments on commit d158bb0

Please sign in to comment.