Also configure a plugin to be lazy-loaded on a given command or key.
Restart Neovim and trigger the command/key to load the plugin.
Actual behaviour
The autocommand will be triggered by the loading of the plugin.
Expected behaviour
No external autocommand will be triggered by the loading of the plugin.
Workaround
Put a condition in the autocommand to make it trigger only once per buffer:
vim.api.nvim_create_autocmd("BufReadPost", {callback = function()
if not vim.b.my_autocmd_triggered then
print("Triggered")
vim.b.my_autocmd_triggered = true
end
end})
nvim --version
: 0.8.0Steps to reproduce
Put the following in your
init.lua
:Also configure a plugin to be lazy-loaded on a given command or key.
Restart Neovim and trigger the command/key to load the plugin.
Actual behaviour
The autocommand will be triggered by the loading of the plugin.
Expected behaviour
No external autocommand will be triggered by the loading of the plugin.
Workaround
Put a condition in the autocommand to make it trigger only once per buffer: