Git hunks and mapping

Heya! I recently got into Kakoune.

I’m trying to setup a keymap to be able to jump between git diffs. Ideally the keymap would be ]h for next-hunk and [h for previous hunk.

I figured I can use a “object” mapping like this

map global object h '<a-semicolon>git next-hunk<ret>'

but obviously that can only make me go forward, ideally I’d need a way to go back as well for [h, how can I set that?

Am I missing something or you missed :git prev-hunk?

look at how GitHub - Delapouite/kakoune-text-objects: Extra text-objects does it. They define an objects_last_mode option

What I settled on was


declare-user-mode hunk

map global hunk ] ':git next-hunk<ret>' -docstring 'Git hunk next'
map global hunk [ ':git prev-hunk<ret>' -docstring 'Git hunk prev'
map -docstring 'Goto hunk' global user h ': enter-user-mode hunk<ret>'

and then it is mapped to a user mode instead. I think that is more kakoune-y