From d97f914e940c46da99864a7c2fb99ac3028ea843 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 3 Jul 2023 14:30:31 +0000 Subject: [PATCH] chore(doc): auto-generate vimdoc --- doc/auto-save.nvim.txt | 51 +++++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/doc/auto-save.nvim.txt b/doc/auto-save.nvim.txt index 3b16157..fc938df 100644 --- a/doc/auto-save.nvim.txt +++ b/doc/auto-save.nvim.txt @@ -1,4 +1,4 @@ -*auto-save.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 April 30 +*auto-save.nvim.txt* For Neovim >= 0.8.0 Last change: 2023 July 03 ============================================================================== Table of Contents *auto-save.nvim-table-of-contents* @@ -12,8 +12,9 @@ Table of Contents *auto-save.nvim-table-of-contents* 4. Configuration |auto-save.nvim-configuration| - Condition |auto-save.nvim-configuration-condition| 5. Usage |auto-save.nvim-usage| -6. Contributing |auto-save.nvim-contributing| -7. Acknowledgements |auto-save.nvim-acknowledgements| +6. 🪝 Events / Callbacks |auto-save.nvim-🪝-events-/-callbacks| +7. Contributing |auto-save.nvim-contributing| +8. Acknowledgements |auto-save.nvim-acknowledgements| ============================================================================== 1. Features *auto-save.nvim-features* @@ -25,7 +26,7 @@ Table of Contents *auto-save.nvim-table-of-contents* - execution message (it can be dimmed and personalized) - events that trigger auto-save - debounce the save with a delay -- multiple callbacks +- hook into the lifecycle with autocommands - automatically clean the message area @@ -113,9 +114,6 @@ VIM-PLUG *auto-save.nvim-installation-vim-plug* condition = nil, write_all_buffers = false, -- write all buffers when the current one meets `condition` debounce_delay = 1000, -- delay after which a pending save is executed - callbacks = { -- functions to be executed at different intervals - before_saving = nil, -- ran before doing the actual save - }, -- log debug messages to 'auto-save.log' file in neovim cache directory, set to `true` to enable debug = false, } @@ -194,7 +192,40 @@ or as part of the `lazy.nvim` plugin spec: ============================================================================== -6. Contributing *auto-save.nvim-contributing* +6. 🪝 Events / Callbacks *auto-save.nvim-🪝-events-/-callbacks* + +The plugin fires events at various points during its lifecycle which users can +hook into: + + +- `AutoSaveWritePre` Just before a buffer is getting saved +- `AutoSaveWritePost` Just after a buffer is getting saved + +It will always supply the current buffer in the `data.saved_buffer` + +An example to always print the file name before a file is getting saved (use +`:messages` if the execution message swallows the print): + +>lua + local group = vim.api.nvim_create_augroup('autosave', {}) + + vim.api.nvim_create_autocmd('User', { + pattern = 'AutoSaveWritePre', + group = group, + callback = function(opts) + if opts.data.saved_buffer ~= nil then + local filename = vim.api.nvim_buf_get_name(opts.data.saved_buffer) + print('We are about to save ' .. filename .. ' get ready captain!') + end + end, + }) +< + +If you want more Events, feel free to open an issue. + + +============================================================================== +7. Contributing *auto-save.nvim-contributing* - All pull requests are welcome. @@ -204,13 +235,13 @@ or as part of the `lazy.nvim` plugin spec: ============================================================================== -7. Acknowledgements *auto-save.nvim-acknowledgements* +8. Acknowledgements *auto-save.nvim-acknowledgements* This plugin wouldn’t exist without Pocco81 ’s work on the original . ============================================================================== -8. Links *auto-save.nvim-links* +9. Links *auto-save.nvim-links* 1. *@commitlint/config-conventional*: