2022-12-06 21:16:39 -03:00
|
|
|
try %{
|
|
|
|
# declare-user-mode surround
|
|
|
|
declare-user-mode git
|
|
|
|
}
|
|
|
|
|
|
|
|
map global user 'v' ': enter-user-mode git<ret>' -docstring 'git vcs mode'
|
|
|
|
map global user 'V' ': enter-user-mode -lock git<ret>' -docstring 'git vcs mode'
|
2023-02-14 17:50:49 -03:00
|
|
|
|
|
|
|
# show status
|
2022-12-06 21:16:39 -03:00
|
|
|
map global git 's' ': git status<ret>' -docstring 'status'
|
|
|
|
map global git 'S' '_: git show %val{selection} --<ret>' -docstring 'show'
|
2023-02-14 17:50:49 -03:00
|
|
|
map global git 'g' ': git-graph <ret>' -docstring 'graph all commits'
|
|
|
|
map global git 'G' ': git-graph-simpified <ret>' -docstring 'graph all branches'
|
2023-02-23 12:29:37 -03:00
|
|
|
map global git '<a-g>' ': git-graph-with-remotes<ret>' -docstring 'graph all branches and remotes'
|
2022-12-06 21:16:39 -03:00
|
|
|
map global git 'd' ': git diff %reg{%}<ret>' -docstring 'diff current'
|
|
|
|
map global git 'D' ': git diff<ret>' -docstring 'diff all'
|
|
|
|
map global git '<a-d>' ': git diff --staged<ret>' -docstring 'diff staged'
|
2023-02-14 17:50:49 -03:00
|
|
|
|
2023-02-23 12:29:37 -03:00
|
|
|
map global git 'n' ': git next-hunk <ret>' -docstring 'next git modification'
|
|
|
|
map global git 'p' ': git prev-hunk <ret>' -docstring 'previous git modification'
|
|
|
|
|
2023-02-14 17:50:49 -03:00
|
|
|
# make commits
|
|
|
|
map global git 'a' ': git add<ret>' -docstring 'add current'
|
|
|
|
map global git 'A' ': git add --all<ret>' -docstring 'add all'
|
2022-12-06 21:16:39 -03:00
|
|
|
map global git 'c' ': git commit -v<ret>' -docstring 'commit'
|
2023-02-14 17:50:49 -03:00
|
|
|
|
|
|
|
# discard work
|
|
|
|
map global git 'r' ': git checkout %reg{%}<ret>' -docstring 'restore current'
|
|
|
|
|
|
|
|
# deal with merges
|
2023-02-23 12:29:37 -03:00
|
|
|
map global git 'N' ': git-next-merge-conflict <ret>' -docstring 'next git merge conflict'
|
|
|
|
map global git 'P' ': git-prev-merge-conflict <ret>' -docstring 'previous git merge conflict'
|
2022-12-06 21:16:39 -03:00
|
|
|
map global git 'm' ': git-merge-head <ret>' -docstring 'merge using head'
|
|
|
|
map global git 'M' ': git-merge-new <ret>' -docstring 'merge using new'
|
2024-06-21 15:08:44 -03:00
|
|
|
map global git '<c-m>' ': git-merge-head-and-new <ret>' -docstring 'merge using both head and new'
|
2022-12-06 21:16:39 -03:00
|
|
|
map global git '<a-m>' ': git-merge-original <ret>' -docstring 'merge using original'
|
|
|
|
|
2023-02-23 12:29:37 -03:00
|
|
|
define-command -override git-next-merge-conflict %{
|
2023-02-14 17:50:49 -03:00
|
|
|
try %{
|
|
|
|
execute-keys /^<lt>{6,}.*?^<gt>{6,}.*?$<ret>
|
|
|
|
} catch %{
|
|
|
|
fail "No hunks found forward"
|
|
|
|
}
|
|
|
|
} -docstring "next git merge hunk"
|
|
|
|
|
2023-02-23 12:29:37 -03:00
|
|
|
define-command -override git-prev-merge-conflict %{
|
2023-02-14 17:50:49 -03:00
|
|
|
try %{
|
|
|
|
execute-keys <a-/>^<lt>{6,}.*?^<gt>{6,}.*?$<ret>
|
|
|
|
} catch %{
|
|
|
|
fail "No hunks found backwards"
|
|
|
|
}
|
|
|
|
} -docstring "previous git merge hunk"
|
|
|
|
|
2022-12-06 21:16:39 -03:00
|
|
|
define-command -override git-merge-head %{
|
|
|
|
evaluate-commands -draft %{
|
|
|
|
# delete head marker
|
2024-02-12 10:54:14 -03:00
|
|
|
execute-keys <a-/>^<lt>{4,}<ret>xd
|
2022-12-06 21:16:39 -03:00
|
|
|
try %{
|
|
|
|
# select original marker
|
|
|
|
execute-keys /^[|]{4,}<ret>
|
|
|
|
# extend to theirs marker
|
2024-02-12 10:54:14 -03:00
|
|
|
execute-keys ?^={4,}<ret>x
|
2022-12-06 21:16:39 -03:00
|
|
|
} catch %{
|
|
|
|
# select theirs marker
|
2024-02-12 10:54:14 -03:00
|
|
|
execute-keys /^={4,}<ret>x
|
2022-12-06 21:16:39 -03:00
|
|
|
}
|
|
|
|
# extend to end marker
|
2024-02-12 10:54:14 -03:00
|
|
|
execute-keys ?^<gt>{4,}<ret>xd
|
2022-12-06 21:16:39 -03:00
|
|
|
}
|
|
|
|
} -docstring "merge using head"
|
|
|
|
|
|
|
|
define-command -override git-merge-original %{
|
|
|
|
evaluate-commands -draft %{
|
|
|
|
# select head marker
|
|
|
|
execute-keys <a-/>^<lt>{4,}<ret>
|
|
|
|
# select to middle of conflict
|
2024-02-12 10:54:14 -03:00
|
|
|
execute-keys ?^[|]{4,}<ret>xd
|
2022-12-06 21:16:39 -03:00
|
|
|
# select theirs marker
|
|
|
|
execute-keys /^={4,}<ret>
|
|
|
|
# extend to end marker
|
2024-02-12 10:54:14 -03:00
|
|
|
execute-keys ?^<gt>{4,}<ret>xd
|
2022-12-06 21:16:39 -03:00
|
|
|
}
|
|
|
|
} -docstring "merge using original"
|
|
|
|
|
|
|
|
define-command -override git-merge-new %{
|
|
|
|
evaluate-commands -draft %{
|
|
|
|
# select head marker
|
|
|
|
execute-keys <a-/>^<lt>{4,}<ret>
|
|
|
|
# extend to theirs marker
|
|
|
|
execute-keys ?^={4,}\n<ret>d
|
|
|
|
# delete end marker
|
2024-02-12 10:54:14 -03:00
|
|
|
execute-keys /^<gt>{4,}<ret>xd
|
2022-12-06 21:16:39 -03:00
|
|
|
}
|
|
|
|
} -docstring "merge using new"
|
2023-02-14 17:50:49 -03:00
|
|
|
|
2024-06-21 15:08:44 -03:00
|
|
|
define-command -override git-merge-head-and-new %{
|
|
|
|
evaluate-commands -draft %{
|
|
|
|
# delete head marker
|
|
|
|
execute-keys <a-/>^<lt>{4,}<ret>xd
|
|
|
|
# select middle of conflict
|
|
|
|
execute-keys /^[|]{4,}<ret>x
|
|
|
|
# extendo to theirs marker
|
|
|
|
execute-keys ?^={4,}<ret>xd
|
|
|
|
# delete end marker
|
|
|
|
execute-keys /^<gt>{4,}<ret>xd
|
|
|
|
}
|
|
|
|
} -docstring "merge using head and new"
|
|
|
|
|
2023-02-14 17:50:49 -03:00
|
|
|
define-command -override git-graph %{
|
|
|
|
try %{ delete-buffer '*git-graph*' }
|
|
|
|
edit -scratch '*git-graph*'
|
2023-02-23 12:29:37 -03:00
|
|
|
execute-keys '<a-!> timeout 10s git graph --color=always --decorate --branches<ret>'
|
2023-02-14 17:50:49 -03:00
|
|
|
execute-keys 'gg'
|
|
|
|
try ansi-render
|
|
|
|
map buffer normal q ': delete-buffer!<ret>'
|
|
|
|
}
|
|
|
|
|
|
|
|
define-command -override git-graph-simpified %{
|
|
|
|
try %{ delete-buffer '*git-graph*' }
|
|
|
|
edit -scratch '*git-graph*'
|
|
|
|
execute-keys '<a-!> timeout 10s git graph --color=always --decorate --all --simplify-by-decoration<ret>'
|
|
|
|
execute-keys 'gg'
|
|
|
|
try ansi-render
|
|
|
|
map buffer normal q ': delete-buffer!<ret>'
|
|
|
|
}
|
2023-02-23 12:29:37 -03:00
|
|
|
|
|
|
|
define-command -override git-graph-with-remotes %{
|
|
|
|
try %{ delete-buffer '*git-graph*' }
|
|
|
|
edit -scratch '*git-graph*'
|
|
|
|
execute-keys '<a-!> timeout 10s git graph --color=always --decorate --all<ret>'
|
|
|
|
execute-keys 'gg'
|
|
|
|
try ansi-render
|
|
|
|
map buffer normal q ': delete-buffer!<ret>'
|
|
|
|
}
|