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

Feature request: set delay before autosaving #61

Open
okuuva opened this issue Oct 9, 2022 · 3 comments
Open

Feature request: set delay before autosaving #61

okuuva opened this issue Oct 9, 2022 · 3 comments

Comments

@okuuva
Copy link

okuuva commented Oct 9, 2022

It would be nice to be able to set a delay before autosave is run after receiving trigger event.

Use case: I use tidy because cleaning up trailing whitespaces is a task best left to automation. Using tidy with auto-save.nvim makes pasting stuff from registers at the end of line / file hard because file is automatically saved (and thus cleaned of traling spaces / lines) immediately after exiting insert mode.

Setting debounce_delay doesn't help because if I understood it correctly it only prevents the same buffer getting saved multiple times during the given time frame and it still saves the buffer immediately if it hasn't already been saved during that time frame.

@okuuva
Copy link
Author

okuuva commented Oct 9, 2022

I think I might be able to implement this with an autocommand that emits a custom event after a given delay when it receives a triggering event. If somebody has any better ideas I'm all ears.

@ehaynes99
Copy link

This is a problem with tidy, not auto-save. It should allow specifying the event that triggers it, but it's hardcoded:

https://github.com/mcauley-penney/tidy.nvim/blob/9b15a0eb12d6d4f0bb5c197c1f5b72bcc57f09ff/lua/tidy/init.lua#L49

vim.api.nvim_create_autocmd("BufWritePre", {

Ideally, we could get some sort of grouping mechanism for these "auto-whatever" plugins, but as a largely enthusiast group of authors, it's not easy to synchronize.

@okuuva
Copy link
Author

okuuva commented Nov 29, 2022

That is indeed a problem with tidy but I still think it would be nice to have a user specified delay before autosave. If nothing more it would act as a workaround for other auto-plugins with no configuration options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants