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