fix: get correct list of ft and cmd from lazy function #442
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.
The current approach of getting the
ft
andcmd
values fromlazy.nvim
only consider the last spec definition of thelazy.nvim
configuration.If the plugin spec is defined in 2 places it will create metatables and it will just get the
ft
defined in the last definition.Example:
Spec definition run first:
Second spec definition somewhere else in your config, ran last:
This creates a structure like this after inspecing the plugin in the Lazy UI:
However we can use the final value list of
ft
orcmd
that lazy resolves:Lazy always resolves
ft
andcmd
to a list and thisvalues
function fromlazy.core.plugin
already returns an empty table{}
when no values are set.Note: these values are set when
lazy.nvim
loads and resolves them, inside thevalues
method it sets the cache if it's not set but it will be set by the time the plugin runs. If this repo don't want to use this method because it sets cache if not set, then I could try to find a way to queryplugin._.cache[key]
directly. Nevertheless I think this PR implementation is safe.