feat(plugins): Given an optional plugin, conditionally discard deps #947
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 plugin will never load, unless the aforementioned keys are pressed, resulting in an error.
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.
References