Repository navigation
fix(merge): clear opts keys set to vim.NIL - #47
Merged
Merged
Conversation
lazy.nvim's merge treats vim.NIL as "remove this key", so
{ opts = { a = { x = 1 } } } + { opts = { a = vim.NIL } } drops `a`.
resolve_opts copied vim.NIL into the result instead, and setup() got
a = vim.NIL. After vim.tbl_deep_extend, walk the incoming opts along
the tables it merged and remove their vim.NIL keys. Only the tables
vim.tbl_deep_extend made are written to, so specs' opts are untouched;
a table that replaced the earlier value, a list, and function-form
opts keep their vim.NIL, as in lazy.nvim.
Behaviour change: a vim.NIL at a merged key (e.g. a JSON null in LSP
settings) no longer reaches the plugin; the vimdoc and tips.md say how
to pass one.
Refs zpack_nvim-0eg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
lazy.nvim's opts merge treats
vim.NILas "remove this key", so a later spec can drop an option an earlier one set:{ 'user/plugin', opts = { a = { x = 1 } } } { 'user/plugin', opts = { a = vim.NIL } } -- lazy.nvim: `a` is removedzpack passed the userdata through instead, so
setup()receiveda = vim.NILand code likeopts.a.xthrew. Aftervim.tbl_deep_extend,merge_optsnow walks the incoming opts along the tables it merged and removes theirvim.NILkeys. Only tablesvim.tbl_deep_extendcreated are written to, so specs' own opts are never edited.As in lazy.nvim,
vim.NILis removed only where specs merge: at the top level of opts (unless these or the earlier opts are a non-empty list) and in a table merged into the one an earlier spec set at the same place. A table that replaces the earlier value (nothing, a scalar or a list was there, or it is a list itself) keeps itsvim.NIL, and so do opts a function returns or edits.Behaviour change: a
vim.NILat a merged key (e.g. a JSONnullin LSP settings) no longer reaches the plugin. lazy.nvim users already can't do that; the vimdoc anddocs/tips.mdsay how to still pass anull.optsentry anddocs/tips.mdGotchas documentvim.NILvim.NILis kept, specs' opts staying untouched across resolves, and an FFI cdata's__eqnever being called (rawequal)Util.mergeon ~20k one-, two- and three-spec chains of opts shapes: no chain diverges from lazy.nvim that didn't onmain, and 8,123 that did now match. The rest are existing differences:vim.tbl_deep_extendmerges top-level list opts by index and drops a merged object's metatableRebuilt on
mainafter #46 merged with its reworkedvim.tbl_deep_extendmerge. The earlier lazy.nvim merge rewrite on this branch is dropped.