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

feat(plugins): Given an optional plugin, conditionally discard deps #947

Merged
merged 5 commits into from
Jul 22, 2023
Merged

feat(plugins): Given an optional plugin, conditionally discard deps #947

merged 5 commits into from
Jul 22, 2023

Conversation

abeldekat
Copy link
Contributor

Currently, when a plugin is marked with "enabled = false", lazy.nvim investigates the dependencies of that plugin,and disables them when appropriate.
Such behaviour is not implemented for a plugin marked with "optional = true".

Example

Consider a stock LazyVim installation with "extras/lang/python" added to "config/lazy.lua"
The resulting installation includes nvim-dap-python and its keys, but without nvim-dap installed.

Pressing <leader> d P c leads to an error.
The UI of which-key shows "prefix" as description for "d".

The cause

In "extras/lang/python", nvim-dap-python is a dependency of nvim-dap.
When "extras/dap/core" is not added to "config/lazy.lua", nvim-dap becomes completely optional and will not be installed.
Currently, the dependency of nvim-dap, nvim-dap-python, does get installed.

Note: This pattern applies to multiple configs in extras.

Is it a problem?

If the user wants to use "extras/lang/python" without "extras/dap/core", the following options are available:

  • the user accepts a plugin he has no benefit of.
    The plugin will never load, unless the aforementioned keys are pressed, resulting in an error.
  • the user explicitly disables nvim-dap-python
  • the maintainer moves nvim-dap to its own python specific config.
    The user now needs to include both python configs for complete functionality.

Implementation

This is relatively straightforward, reusing the existing algorithm doing the disabling of explicitly disabled plugins.

  • The user might see some unexpected plugins to be cleaned in the UI of lazy.nvim.
  • Performance is not expected to degrade. I did not observe a decline.

References

@folke folke merged commit e7334d8 into folke:main Jul 22, 2023
@folke
Copy link
Owner

folke commented Jul 22, 2023

Merged, thanks!

@abeldekat
Copy link
Contributor Author

You are most welcome. Happy to contribute!

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

Successfully merging this pull request may close these issues.

None yet

2 participants