Skip to content

Conversation

@AlexanderArvidsson
Copy link
Contributor

@AlexanderArvidsson AlexanderArvidsson commented Apr 16, 2025

Adds the ability to add custom argument switches to any popups by allowing users to create custom builder hooks to modify popups while they're building.
image

The above is implemented in config like this to provide the -o merge_request.create GitLab specific option:

require('neogit').setup({
  builders = {
    NeogitPushPopup = function(builder)
      --
      builder:switch('m', 'merge_request.create', 'Create merge request', { cli_prefix = '-o ', persisted = false })
    end,
  },
})

This PR also introduces the persisted = false option for switches, and it also migrates all existing non-persisted switches to this flag instead of the ignored_settings option. It doesn't remove ignored_settings, as people might have overridden it.
It also adds persisted = false to some extra popups that wasn't covered before (mostly force switches).

Fixes #1684.

Future changes

  • Modify existing switches' options, to change their keybinds, text, persisted option, etc.
  • Set an ordering for switches, or the ability to inject new options anywhere in the list.

@CKolkey
Copy link
Member

CKolkey commented Apr 16, 2025

Good stuff! A quick look at the code doesn't show any glaring issues. But would you mind adding some documentation to the help file? Under API or something that makes sense :)

@AlexanderArvidsson
Copy link
Contributor Author

I added some docs under neogit_custom_popups and also updated the references to the default config, which has now changed (migrated to persisted flags, it shouldn't introduce any breaking changes afaict.

Let me know if you want to make some changes or move it somewhere else!

@CKolkey CKolkey force-pushed the feature/1684-custom-popup-builder-callable branch from be0a5ad to b03d807 Compare April 20, 2025 08:19
@CKolkey CKolkey force-pushed the feature/1684-custom-popup-builder-callable branch from b03d807 to 0d63794 Compare May 3, 2025 18:39
@CKolkey
Copy link
Member

CKolkey commented May 3, 2025

This is great, thanks a ton for implementing it!

@CKolkey CKolkey merged commit dd361c3 into NeogitOrg:master May 3, 2025
8 of 12 checks passed
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.

Ability to add custom predefined argument switches to the push menu

2 participants