-
-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib/helpers: add deprecation.mkTransitionOptionModule
#1657
base: main
Are you sure you want to change the base?
lib/helpers: add deprecation.mkTransitionOptionModule
#1657
Conversation
`helpers.deprecation.mkTransitionOptionModule` is similar to `lib.mkRenamedOptionModule`, however it instead warns users that the option was renamed to avoid confusion, and will eventually be transitioned to the new option.
Maybe we should use NixOS releases as takeovers globally in nixvim? |
I agree, I think that'll make things easier for stable users upgrading and we'll also have an obvious reminder of when we need to go through and remove old deprecations. Although, personally I'm in favor of not removing old deprecations where possible.* Instead we could move them somewhere less obnoxious, like * e.g. you can't avoid a transition warning needing to be removed when |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments for discussion of the actual code.
But I don't think this should be merged until after we all agree on how we should handle the kinda name conflicts this helper attempts to resolve (i.e. #1371 and #1352). Otherwise we've just got dead code laying around!
Happy to discuss here or on matrix.
@@ -15,6 +15,7 @@ in | |||
maintainers = import ./maintainers.nix; | |||
keymaps = import ./keymap-helpers.nix { inherit lib nixvimOptions nixvimTypes; }; | |||
autocmd = import ./autocmd-helpers.nix { inherit lib nixvimOptions nixvimTypes; }; | |||
deprecation = import ./deprecation-helpers.nix { inherit lib nixvimUtils; }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've scoped this for now. Would you rather it be a top-level helper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think scoped is nicer
opt = getAttrFromPath from options; | ||
toOpt = getAttrFromPath to options; | ||
in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should produce useful error messages when used incorrectly:
opt = getAttrFromPath from options; | |
toOpt = getAttrFromPath to options; | |
in | |
get = path: attrByPath path (abort "mkTransitionOptionModule: can't find option `${showOption path}`") options; | |
opt = get from; | |
toOpt = get to; | |
in | |
# Also assert `future` exists | |
# get will abort before the assert does, only used to force it to evaluate | |
assert (get future) != null; |
to, | ||
# The new option; will takeover `from` in the future | ||
future, | ||
# The date or release after which `future` will be moved to `from`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #1657 (comment)
# The date or release after which `future` will be moved to `from`. | |
# The nixos release after which `future` will be moved to `from`. |
?
helpers.deprecation.mkTransitionOptionModule
is similar tolib.mkRenamedOptionModule
, however it instead warns users that the option was renamed to avoid confusion, and will eventually be transitioned to the new option.The implementation is basically identical to
lib.doRename
.This is intended as one possible solution to #1371 and #1352.
If we go down this route, we would introduce the new plugins as
-nvim
variants, rename the old plugins to-vim
and add a transition alias warning users that the un-suffixed name will transition to the-nvim
option.plugins.surround
in their config would get a transition warning.surround-nvim
aliasI've tested this by adding the following to surround.vim's
imports
and changingname
to"surround-vim"
:This produces the following warning when used with a config that contains
plugins.surround.enable = true
:It's a shame multiline trace warnings are so ugly, so I'd appreciate suggestions for making it more readable. The first line of the warning is based on the warning used by
lib.doRename
.