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: user autocmd event when syncing/updating is complete #135

Closed
1 task done
mehalter opened this issue Dec 23, 2022 · 5 comments · Fixed by #129
Closed
1 task done

feature: user autocmd event when syncing/updating is complete #135

mehalter opened this issue Dec 23, 2022 · 5 comments · Fixed by #129
Labels
enhancement New feature or request

Comments

@mehalter
Copy link

Did you check docs the docs?

  • I have read all the lazy docs

Is your feature request related to a problem? Please describe.

It would be nice to have autocmd user events when lazy finishes updating/installing plugins so the user can easily trigger things to happen.

Describe the solution you'd like

After an update/install is finished and all of the install handlers are finished do something like vim.cmd("do User LazyComplete") or some other name to indicate it has finished updating/installing plugins.

Describe alternatives you've considered

I'm not sure of any other alternatives to be able to tell when Lazy is finished.

Additional context

This is also useful if a user wants to do a headless setup of their neovim config on a fresh install with something like nvim --headless -c 'autocmd User LazyComplete quitall'

This is also something that other package managers do like Packer which emits the user event PackerComplete

@mehalter mehalter added the enhancement New feature or request label Dec 23, 2022
@folke
Copy link
Owner

folke commented Dec 23, 2022

for headless install you can do nvim --headless "+Lazy! sync" +qa as is mentioned in the docs.

You can also use the API and pass in wait=true to wait till the operation finishes.

The user commands can be executed with a bang, which makes them also wait till they finished.

It's all in the docs.

What's your specific use-case?

There is also LazyDone which is triggered when lazy is finished setting up during startup. Need to document that one.

@kylo252
Copy link
Contributor

kylo252 commented Dec 23, 2022

What's your specific use-case?

@folke, it would be useful for pseudo hot-reloading, e,g. refreshing elements of the UI after the plugins have been updated.

  vim.api.nvim_create_autocmd("User", {
    pattern = "LazyComplete",
    once = true,
    callback = function()
        vim.api.nvim_exec_autocmds("ColorScheme", {pattern = "*"})
		-- vim.notify("Update/Sync/Something is complete!")
    end,
  })

@folke
Copy link
Owner

folke commented Dec 24, 2022

📆 User Events

The following user events will be triggered:

  • LazyDone: when lazy has finished starting up and loaded your config
  • LazySync: after running sync
  • LazyInstall: after an install
  • LazyUpdate: after an update
  • LazyClean: after a clean
  • LazyCheck: after checking for updates
  • LazyLog: after running log

@mosheavni
Copy link
Contributor

Pardon @folke but isn't VeryLazy one of them?

@folke
Copy link
Owner

folke commented Dec 24, 2022

Right, need to add that one to the list

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

Successfully merging a pull request may close this issue.

4 participants