nixvim icon indicating copy to clipboard operation
nixvim copied to clipboard

lib/neovim-plugin: Add lazyLoad option to plugins

Open psfloyd opened this issue 1 year ago • 7 comments

This PR is the second split of PR #1866, it works on a solution for the issue #421. This PR depends on PR #1874. All suggestions from the original PR are included.

Design description

The idea is to automatically create lazyLoad option for all plugins that are defined with mkNeovimPlugin. lazyLoad is conformed by triggers (e.g. filetype, event, key, command) and actions (e.g. functions to run before/after loading the plugin). mkNeovimPlugin would also generate default values for some of these options (e.g. the setup).

Plugin maintainers can decide to not create the lazyLoad option, by setting allowLazyLoading to false when defining the plguin.

Plugin maintainers can provide sensible default values to lazyLoad when defining a plugin. For example, if defining telescope.nvim, set Telescope as a command trigger. Also defining a custom setup function if they are setting callSetup as false.

Finnally users can :

  • Enable lazy-loading (globally or on a per-plugin basis)
  • Add to these triggers (or override them with mkForce) on a per-plugin basis.
  • Override actions on a per-plugin basis.

Progress

  • [x] Adding mkLazyLoadOption to generate lazyLoad options for plugins.
  • [x] Conditionally enabling lazy or regular loading depending on user settings in mkNeovimPlugin.
  • [x] Adding and implementing a lazy-loading mechanism using lz.n.
  • [ ] Adding and implementing a lazy-loading mechanism using lazy.nvim.
  • [ ] Assert that only one of the backends is enabled.
  • [ ] Conditionally enabling lazy or regular loading depending on user settings in mkVimPlugin.

psfloyd avatar Jul 16 '24 06:07 psfloyd