feat(core): If a plugin is not enabled, ignore all specs in its dependencies #1000
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.
Example scenario:
Plugin B is
disabled
.However, both definitions of A are merged into the final A:
A.opts == { foo = true, bar = true }
<leader>ab
is present, and will fail when invoked, on the absence of B.Note that currently, when A would only exist as a dependency of B, plugin A would have been
disabled
as well.The configuration of a plugin can depend on the presence of another plugin.
A good example is the conditional definition of a key.
Currently, extra code is required, checking for the presence of a plugin using programmatic "guards".
This PR ensures that plugin A only contains the definition provided by plugin B, if B is
enabled
.The result becomes:
A.opts == { foo = true }
<leader>ab
is not available.An opinion on the benefits
An opinion on the implications
This PR will most likely not break existing personal configurations.
Users might have expected the behaviour this PR aims for to already be in effect.
Distributions however are highly modularized by nature. Maintainers are advised to inspect the code.
Consider a definition of A inside B, containing a property that should always be present on A regardless of the status of B.
Breaking example:
In this case, it would make sense to move the configuration of property
ALWAYS_NEEDED
to the top-level spec of plugin A.Approach
This PR changes the
Plugin.parse
method, after all specs have been normalized.An
enabled
plugin will be repaired when it contains a spec originating from thedependencies
property of a plugin that is notenabled
.The
enabled
plugin can be repaired by redoing itsmerge
operation, using a filter on its individual plugin definitions.I did not observe a noticeable decline in performance.
When the user disables many plugins that have specs in their
dependencies
, some performance overhead is expected.Additional context
AstroNvim's lead developer proposed the idea in this discussion. Thanks @mehalter, for all the support!
A scenario illustrating the effect of the proposed changes is discussed in the code review of the following PR: enable telescope extension of nvim-notify.
Worth mentioning: An explanation on how dependencies are loaded, written by Folke in this issue.
While investigating existing issues, I found an issue from @UtkarshVerma, also addressing the topic: Don't process dependencies if spec is disabled.