Skip to content

feat: #1684 Ability to add custom popup switches #1705

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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
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