1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-11-29 10:02:57 +03:00

rc tools git: while blame annotations are shown, map <ret> to "git blame-jump"

Running git blame signals intent to view the blamed commit.  Let's make
`<ret>` to go to that commit+line as long as blame info is shown.

In diff buffers we already use `<ret>` for "diff-jump".

Like blame annotations, the blame-jump mapping lives in window scope.
This means it will not collide with "diff-jump" which is mapped in
buffer scope.

Add the mapping synchronously (unlike the rest of the git-blame code)
to perhaps allow the user to override the mapping:

    git blame; map window normal <ret> ...
This commit is contained in:
Johannes Altmanninger 2024-02-03 00:26:57 +01:00 committed by Maxime Coste
parent 86d940c225
commit 24bf123503

View File

@ -167,6 +167,7 @@ define-command -params 1.. \
printf %s "evaluate-commands -try-client '$kak_opt_docsclient' '
edit! -fifo ${output} *git*
set-option buffer filetype ${filetype}
$(hide_blame)
hook -always -once buffer BufCloseFifo .* ''
nop %sh{ rm -r $(dirname ${output}) }
$(printf %s "${on_close_fifo}" | sed "s/'/''''/g")
@ -176,9 +177,10 @@ define-command -params 1.. \
hide_blame() {
printf %s "
set-option buffer=$kak_bufname git_blame_flags $kak_timestamp
set-option buffer=$kak_bufname git_blame ''
set-option buffer git_blame_flags $kak_timestamp
set-option buffer git_blame %{}
remove-highlighter window/git-blame
unmap window normal <ret> %{:git blame-jump<ret>}
"
}
@ -204,6 +206,8 @@ define-command -params 1.. \
}"
eval $(cat ${kak_response_fifo})
eval "$prepare_git_blame_args"
echo 'map window normal <ret> %{:git blame-jump<ret>}'
echo 'echo -markup {Information}Press <ret> to jump to blamed commit'
(
cd_bufdir
printf %s "evaluate-commands -client '$kak_client' %{