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: Allow plugins to configure their own laziness #338

Open
1 task done
tomodachi94 opened this issue Jan 7, 2023 · 7 comments · May be fixed by #910
Open
1 task done

feature: Allow plugins to configure their own laziness #338

tomodachi94 opened this issue Jan 7, 2023 · 7 comments · May be fixed by #910
Labels
enhancement New feature or request

Comments

@tomodachi94
Copy link

tomodachi94 commented Jan 7, 2023

Did you check the docs?

  • I have read all the lazy.nvim docs

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

Sometimes, setting up Lazy to use lazy-loading can be a little repetitive. The user needs to find a list of commands for the plugin, and then they need to specify them all. This isn't very resilient to plugin updates where commands are added or removed.

Describe the solution you'd like

Plugin developers should be able to specify a file in lua/lazy/_automatic/<pluginName>.lua1which gets required2 by Lazy itself. The automatic setup file should return a table with all of the Lazy triggers: cond, event, cmd, and ft. It should not be able to set anything else, including priority.

This automatic setup should only be triggered if lazy is set to true. User-specified values should overwrite pre-determined values.

Describe alternatives you've considered

See "Is your feature request related to a problem".

Additional context

The trouble with this is finding a way to use "path safe" plugin names, as require interprets a dot . as a slash /.

Footnotes

  1. I modeled the name after Telescope's _extensions submodule. It can be whatever.

  2. Something like require("lazy._automatic" .. pluginName) would work, plus it looks clean.

@tomodachi94 tomodachi94 added the enhancement New feature or request label Jan 7, 2023
@tomodachi94
Copy link
Author

tomodachi94 commented Jan 7, 2023

Perhaps there should be a new option, automatic, which could be set to false to completely disable this functionality.

Alternatively, it could require setting automatic and lazy to true, which would be less shocking for the end-user.

@tomodachi94
Copy link
Author

Another thing I forgot to mention is if we should let this functionality manage dependencies (I think we shouldn't, it's too easy to screw up and doesn't account for non-plugin dependencies).

@folke
Copy link
Owner

folke commented Jan 7, 2023

That's already planned.

@folke folke closed this as not planned Won't fix, can't repro, duplicate, stale Jan 7, 2023
@tomodachi94
Copy link
Author

That's already planned.

Ah, my bad.

@tomodachi94
Copy link
Author

tomodachi94 commented Jan 7, 2023

@folke, if you need help implementing this, I'm more than willing to help.

@folke folke reopened this Jan 7, 2023
@folke
Copy link
Owner

folke commented Jan 7, 2023

I first need to think this through to keep everything performant.
I'm probably going to disallow the usage of functions inside plugins' specs, so that all that data can be cached and only needs to be updated when a plugin updates.

I would actually allow using these files even when the default for lazy is false, since if something's not working due to lazy-loading, it's the plugin dev that needs to fix it anyway.

I'll keep this issue open for now.

@folke
Copy link
Owner

folke commented Jan 7, 2023

I'm also looking to support https://github.com/nvim-lua/nvim-package-specification directly.

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.

2 participants