Skip to content
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

plugins/which-key: migrate to mkNeovimPlugin #1990

Merged
merged 1 commit into from
Aug 8, 2024

Conversation

khaneliman
Copy link
Contributor

@khaneliman khaneliman commented Aug 5, 2024

Working on converting this and there are a few breaking changes for data types of config options https://github.com/folke/which-key.nvim/pull/624/files#diff-a8347a13956b70b044d3e091cd3115e2fcfb44d4ebde516ff03223b2e84c7a7b.

- One being the triggers option which used to be string or list of strings, but is now a list of attribute sets like the registrations change. What should we do in that case?
Very niche setting, continuing with breaking change.
- Another issue I was hoping for clarification on is nested properties moving to settings and moving to a different path within settings.
Resolved, most can be just parent level rename. Manually specified those that wouldn't be handled properly for nested.
- plugins -> presets -> textObjects moved and changed from camel to snake case. Does that get handled from the normal optionsRenamedToSettings?
^
- windows -> winblend moved to win -> wo -> winblend. i'm unable to make a mkRenamedOption for that while also using the optionsRenamedToSettings for the parent object because of the order of evaluation, it seems. Will I need to explicitly remap all of those or just handle the deprecation like registrations and support forwarding the previous config through, for now?
Created a deprecation warning for the window setting, dont need to worry about the child setting since it's mentioned in the warning that the options have changed.

Lots of TODO notes and some temporary test stuff for testing out renaming and warnings that can be ignored/questions answered

@khaneliman khaneliman force-pushed the which-key branch 3 times, most recently from e60b241 to a8ae43e Compare August 6, 2024 05:12
@MattSturgeon
Copy link
Member

MattSturgeon commented Aug 6, 2024

Working on converting this and there are a few breaking changes for data types of config options folke/which-key.nvim#624 (files).

TBH, 90% of users probably don't have much config in which-key, other than registrations. I don't think we have to gracefully transition all changes to the v3 scheme. Rather mkRemovedOptionModule with clear migration instructions would be enough for lesser used options or anything particularly complex.

  • One being the triggers option which used to be string or list of strings, but is now a list of attribute sets like the registrations change. What should we do in that case?

IMO this can be a mkRemovedOptionModule assertion, unless it is trivial to take the same approach as cfg.registrations.

  • Another issue I was hoping for clarification on is nested properties moving to settings and moving to a different path within settings.

  • plugins -> presets -> textObjects moved and changed from camel to snake case. Does that get handled from the normal optionsRenamedToSettings?

optionsRenamedToSettings can handle either string entries or listof-string entries (for nested options). It assumes all renames should use snake_case, so it converts any camelCase option names in the old path to snake_case in the new path.

Here's one example:

optionsRenamedToSettings = [
"debounce"
[
"viewportBuffer"
"min"
]
[
"viewportBuffer"
"max"
]
[
"indent"
"char"
]
[
"indent"
"tabChar"
]
[
"indent"
"highlight"
]
[
"indent"
"smartIndentCap"
]
[
"indent"
"priority"
]
[
"whitespace"
"highlight"
]
[
"whitespace"
"removeBlanklineTrail"
]
[
"scope"
"enabled"
]
[
"scope"
"char"
]
[
"scope"
"showStart"
]
[
"scope"
"showEnd"
]
[
"scope"
"showExactScope"
]
[
"scope"
"injectedLanguages"
]
[
"scope"
"highlight"
]
[
"scope"
"priority"
]
[
"scope"
"include"
"nodeType"
]
[
"scope"
"exclude"
"language"
]
[
"scope"
"exclude"
"nodeType"
]
[
"exclude"
"filetypes"
]
[
"exclude"
"buftypes"
]
];

Note: it's preferred to rename each of the old options, instead of a group of them as otherwise the camelCase/snake_case transformation won't happen for options nested within the group.

If you want anything more bespoke, such as a completely different name, you can manually use mkRenamedOptionModule.

  • windows -> winblend moved to win -> wo -> winblend. I'm unable to make a mkRenamedOption for that while also using the optionsRenamedToSettings for the parent object because of the order of evaluation, it seems.

This is another reason why it's usually better to rename each option rather than a common path containing a group of options.

EDIT: To clarify, renaming a group of options is fine if none of the sub-options are camelCase and you don't need a bespoke rename for any of them.

Will I need to explicitly remap all of those or just handle the deprecation like registrations and support forwarding the previous config through, for now?

Without looking at the actual code (yet), I think renaming all the options is probably better.

Lots of TODO notes and some temporary test stuff for testing out renaming and warnings that can be ignored/questions answered

Thanks for working on this! Don't hesitate to ping as and when you have any questions/issues or would like a code review.

plugins/utils/which-key.nix Outdated Show resolved Hide resolved
plugins/utils/which-key.nix Outdated Show resolved Hide resolved
plugins/utils/which-key.nix Outdated Show resolved Hide resolved
plugins/utils/which-key.nix Outdated Show resolved Hide resolved
plugins/utils/which-key.nix Outdated Show resolved Hide resolved
plugins/utils/which-key.nix Outdated Show resolved Hide resolved
plugins/utils/which-key.nix Outdated Show resolved Hide resolved
@khaneliman khaneliman force-pushed the which-key branch 2 times, most recently from 697fee0 to 5011562 Compare August 6, 2024 16:17
plugins/utils/which-key.nix Outdated Show resolved Hide resolved
plugins/utils/which-key.nix Show resolved Hide resolved
@khaneliman khaneliman force-pushed the which-key branch 8 times, most recently from 2e518a1 to 89330a9 Compare August 7, 2024 20:44
Copy link
Member

@MattSturgeon MattSturgeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've focused this review on the window deprecation. The rest of the changes I've only really skimmed over (so far), but overall they're looking good!

plugins/utils/which-key.nix Outdated Show resolved Hide resolved
plugins/utils/which-key.nix Outdated Show resolved Hide resolved
plugins/utils/which-key.nix Outdated Show resolved Hide resolved
plugins/utils/which-key.nix Outdated Show resolved Hide resolved
@khaneliman khaneliman force-pushed the which-key branch 5 times, most recently from 22d0502 to 6ca176b Compare August 8, 2024 15:12
@khaneliman
Copy link
Contributor Author

Last push is removing the graceful deprecation of window attribute. During testing, the options weren't being used by the actual plugin even though they are listed as just deprecated.

@khaneliman khaneliman marked this pull request as ready for review August 8, 2024 15:13
@khaneliman khaneliman force-pushed the which-key branch 2 times, most recently from 4d584ac to 573f241 Compare August 8, 2024 16:44
@khaneliman
Copy link
Contributor Author

khaneliman commented Aug 8, 2024

Made window.border and window.winblend options renames to gracefully transition users with that config.

Copy link
Member

@MattSturgeon MattSturgeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your continued contributions!

This is looking pretty good, I've tried to focus more on the detail and pick out any nits with this review. The PR is looking more or less done.

It's up to you, but I still wonder if some of the more "internal" feeling options should be omitted from settingsOptions? As discussed before, you can make the judgement call of which options you wish to support until we come up with a policy agreed on by all maintainers.

plugins/utils/which-key.nix Outdated Show resolved Hide resolved
plugins/utils/which-key.nix Outdated Show resolved Hide resolved
plugins/utils/which-key.nix Outdated Show resolved Hide resolved
plugins/utils/which-key.nix Outdated Show resolved Hide resolved
plugins/utils/which-key.nix Outdated Show resolved Hide resolved
plugins/utils/which-key.nix Outdated Show resolved Hide resolved
plugins/utils/which-key.nix Outdated Show resolved Hide resolved
plugins/utils/which-key.nix Outdated Show resolved Hide resolved
plugins/utils/which-key.nix Outdated Show resolved Hide resolved
plugins/utils/which-key.nix Outdated Show resolved Hide resolved
@khaneliman khaneliman force-pushed the which-key branch 10 times, most recently from 24c16fb to 5a7d908 Compare August 8, 2024 20:20
@khaneliman khaneliman requested a review from MattSturgeon August 8, 2024 20:23
Copy link
Member

@MattSturgeon MattSturgeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we're down to the final nits now! 🚀

plugins/utils/which-key.nix Outdated Show resolved Hide resolved
plugins/utils/which-key.nix Show resolved Hide resolved
plugins/utils/which-key.nix Outdated Show resolved Hide resolved
plugins/utils/which-key.nix Outdated Show resolved Hide resolved
Copy link
Member

@MattSturgeon MattSturgeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No more issues from me!

I'm still uncomfortable with having option declarations for all settings-options, but I'm fine with it in the short term if @khaneliman is comfortable maintaining them.

@GaetanLepage @traxys any final feedback before we merge?

@khaneliman thanks again for all your efforts!

@GaetanLepage
Copy link
Member

All good for me. I had a quick browse of the changes and I haven't seen anything too fishy.
I'm OK for declaring all the options, as it is at the maintainer's initiative.

Kudos to both of you for this chunky PR !

@MattSturgeon

This comment was marked as resolved.

This comment was marked as resolved.

@mergify mergify bot merged commit 1adbf11 into nix-community:main Aug 8, 2024
4 checks passed
@mergify mergify bot temporarily deployed to github-pages August 8, 2024 22:00 Inactive
@khaneliman khaneliman deleted the which-key branch August 8, 2024 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants