Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(config): immediately save before quitting or suspending #66

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading