plugins/lsp: correct motivation for onAttach alias impl

Previously I said we alias the definitions instead of the value to allow
`mkOrder` to work correctly. That is incorrect, as order-priorities are
already sorted in `<opt>.definitions`.

The actual reason to use the definitions instead of the final value is
to avoid inf-recursion. The "from" option's `apply` function would read
the "to" option's value, which is defined based on the "from" option's
value, which is set by the "from" option's apply function...

For a one-way binding, `mkDerivedConfig` is best. For a two-way binding,
`mkAliasAndWrapDefsWithPriority` is necessary.
This commit is contained in:
Matt Sturgeon 2025-05-08 02:37:13 +01:00
parent 5fed6b9363
commit 10f899d669
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299

View file

@ -182,15 +182,9 @@ lib.nixvim.plugins.mkNeovimPlugin {
# `mkAliasAndWrapDefinitions` and `mkAliasAndWrapDefsWithPriority` propagates the un-merged
# `definitions`.
#
# This assumes both options have compatible merge functions, but it allows override and order
# priorities to be merged correctly.
#
# E.g:
# lsp.onAttach = mkAfter "world";
# plugins.lsp.onAttach = mkBefore "hello"
# ⇒
# hello
# world
# This assumes both options have compatible merge functions, but not using the final value allows
# implementing a two-way binding in the option's `apply` function. Using `mkDerivedConfig` for a
# two-way binding would result in infinite recursion.
#
# This is equivalent to `mkAliasOptionModule`, except predicated on `plugins.lsp.enable`.
#