feat: add nested option - #83
Conversation
|
Could you explain what problem you are trying to solve here? We have a section for autoformat already in the README. |
|
README instructions for autoformat are complicated and did not work for me at all. Also there are other autocmds that one would like to run on auto save, for example saving sops encrypted buffers. Nested autocmd easily ensures all on-save autocmds will run, without any special configuration needed. If you think this feature isn't needed, then it's okay, no worries. I just think it might be useful for others like me, hence the PR. |
|
I see your point, but I don't get why it shouldn't work. It did the last time I tried but maybe something in neovim core might have changed. Could you adjust the readme as well, especially the part with the autoformat instructions and how it would look like with your new setting? Could you try it out and maybe give us steps to reproduce? So that we can make sure there is an actual problem with autoformat? |
|
This is the config that does not work for me: require("auto-save").setup({
trigger_events = {
defer_save = {},
cancel_deferred_save = {},
},
condition = function(buf)
return vim.api.nvim_get_mode().mode == "n" and vim.bo[buf].buftype == ""
end,
})I have confirmed that deferred save works just fine, buffer is formatted and saved, but I don't need deferred save and immediate auto save does not trigger autoformat. That's why |
|
I wondered why it even worked so far. The reason is that we defer the save for I honestly think the safest option is to set |
|
Fine by me, but it might be a kind of breaking change for some. Maybe we should only set nested to true when noautocmd is false 馃 |
https://neovim.io/doc/user/autocmd/#autocmd-nested
This is very useful for people that want autocommands run when auto-saving. For example auto-format should work without any hassle when this option is turned on.