Custom autocommands on neovim
December 18, 2021
Defining a custom autocommand is very straightforward, it works just like a
native one, with the exception of the keyword User
, example below:
autocmd User MyCustomEvent call my_custom_function()
And this is how you would trigger it:
doautocmd User MyCustomEvent
At the time of writing this, both augroups and autocommands do not have an interface yet, but it’s being worked on pull request #14661
In the mean time, you can either create autocommands in Vimscript or use this wrapper from
norcalli/nvim_utils
Special thanks to:
- Dhruva Sagar on StackOverflow
- nanotee and all the contributors of nvim-lua-guide