folke / lazy.nvim

💤 A modern plugin manager for Neovim
https://lazy.folke.io/
Apache License 2.0
15.07k stars 365 forks source link

feature: Automatically call setup() #1794

Closed metal3d closed 4 weeks ago

metal3d commented 1 month ago

Did you check the docs?

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

As mentionned here: https://github.com/LazyVim/LazyVim/issues/4661 it is a bit confusing, sometimes, to realize why a plugin is not entirely loaded if we didn't set config or opts directive.

For example, I loaded this plugin:

return {
  {
    "icewind/ltex-client.nvim",
  },
}

But no command from the plugin were found.

If I do:

return {
  {
    "icewind/ltex-client.nvim",
    opts = {},
  },
}

So the commands are now present.

Describe the solution you'd like

When no opts or config is set, Lazy should call setup() unless an option tells to not do it.

Describe alternatives you've considered

At this time, no alternative. I need to set config or opts to empty object.

Additional context

Using LazyVim 😄 and I love it 😉

pearagit commented 4 weeks ago

Initializing a lua module with .setup() is a loose convention for lua modules, and setup calls can be quite heavy depending on the plugin. Implicitly calling setup by default is also assuming every plugin with one should not be lazy loaded.

Adding config = true like so does the same thing as opts = {}:

 return {
  {
    "icewind/ltex-client.nvim",
    config = true
  },
}
metal3d commented 4 weeks ago

I agree, it's only that it is a bit confusing when a module isn't loaded after declaring its installation.

folke commented 4 weeks ago

Not all plugins use setup and it's also not always wanted to call setup automatically.

Lazy only calls setup when opts is present.