extract git mode to separate file

This commit is contained in:
Leonardo Eugênio 2022-12-06 21:16:39 -03:00
parent fd79ee3c05
commit 9e737da231
4 changed files with 66 additions and 61 deletions

64
user/kak/git-mode.kak Normal file
View file

@ -0,0 +1,64 @@
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'
map global git 's' ': git status<ret>' -docstring 'status'
map global git 'S' '_: git show %val{selection} --<ret>' -docstring 'show'
map global git 'a' ': git add<ret>' -docstring 'add current'
map global git 'd' ': git diff %reg{%}<ret>' -docstring 'diff current'
map global git 'r' ': git checkout %reg{%}<ret>' -docstring 'restore current'
map global git 'A' ': git add --all<ret>' -docstring 'add all'
map global git 'D' ': git diff<ret>' -docstring 'diff all'
map global git '<a-d>' ': git diff --staged<ret>' -docstring 'diff staged'
map global git 'c' ': git commit -v<ret>' -docstring 'commit'
map global git 'u' ': git update-diff<ret>' -docstring 'update gutter diff'
map global git 'n' ': git next-hunk <ret>' -docstring 'next hunk'
map global git 'p' ': git prev-hunk <ret>' -docstring 'previous hunk'
map global git 'm' ': git-merge-head <ret>' -docstring 'merge using head'
map global git 'M' ': git-merge-new <ret>' -docstring 'merge using new'
map global git '<a-m>' ': git-merge-original <ret>' -docstring 'merge using original'
define-command -override git-merge-head %{
evaluate-commands -draft %{
# delete head marker
execute-keys <a-/>^<lt>{4,}<ret><a-x>d
try %{
# select original marker
execute-keys /^[|]{4,}<ret>
# extend to theirs marker
execute-keys ?^={4,}<ret><a-x>
} catch %{
# select theirs marker
execute-keys /^={4,}<ret><a-x>
}
# extend to end marker
execute-keys ?^<gt>{4,}<ret><a-x>d
}
} -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
execute-keys ?^[|]{4,}<ret><a-x>d
# select theirs marker
execute-keys /^={4,}<ret>
# extend to end marker
execute-keys ?^<gt>{4,}<ret><a-x>d
}
} -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
execute-keys /^<gt>{4,}<ret><a-x>d
}
} -docstring "merge using new"

View file

@ -13,6 +13,7 @@ set global startup_info_version 20200901
source "%val{config}/rc/plug.kak"
source "%val{config}/rc/keys.kak"
source "%val{config}/rc/usermode.kak"
source "%val{config}/rc/git-mode.kak"
source "%val{config}/rc/hooks.kak"
source "%val{config}/rc/filetypes.kak"
source "%val{config}/rc/indent.kak"

View file

@ -1,6 +1,5 @@
try %{
# declare-user-mode surround
declare-user-mode git
declare-user-mode find
}
@ -26,24 +25,6 @@ map global user 'b' ': find_buffer<ret>' -docstring 'switch buffer'
map global user 'l' ': lsp-enable-decals<ret>' -docstring 'LSP enable decals'
map global user 'L' ': lsp-disable-decals<ret>' -docstring 'LSP disable decals'
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'
map global git 's' ': git status<ret>' -docstring 'status'
map global git 'S' '_: git show %val{selection} --<ret>' -docstring 'show'
map global git 'a' ': git add<ret>' -docstring 'add current'
map global git 'd' ': git diff %reg{%}<ret>' -docstring 'diff current'
map global git 'r' ': git checkout %reg{%}<ret>' -docstring 'restore current'
map global git 'A' ': git add --all<ret>' -docstring 'add all'
map global git 'D' ': git diff<ret>' -docstring 'diff all'
map global git '<a-d>' ': git diff --staged<ret>' -docstring 'diff staged'
map global git 'c' ': git commit -v<ret>' -docstring 'commit'
map global git 'u' ': git update-diff<ret>' -docstring 'update gutter diff'
map global git 'n' ': git next-hunk <ret>' -docstring 'next hunk'
map global git 'p' ': git prev-hunk <ret>' -docstring 'previous hunk'
map global git 'm' ': git-merge-head <ret>' -docstring 'merge using head'
map global git 'M' ': git-merge-new <ret>' -docstring 'merge using new'
map global git '<a-m>' ': git-merge-original <ret>' -docstring 'merge using original'
map global user 'f' ': enter-user-mode find<ret>' -docstring 'find mode'
map global find 't' ': tree<ret>' -docstring 'file tree'
map global find 'f' ': find_file<ret>' -docstring 'file'
@ -136,45 +117,3 @@ zoxide %{
define-command -override config-source %{
source "%val{config}/kakrc"
}
define-command -override git-merge-head %{
evaluate-commands -draft %{
# delete head marker
execute-keys <a-/>^<lt>{4,}<ret><a-x>d
try %{
# select original marker
execute-keys /^[|]{4,}<ret>
# extend to theirs marker
execute-keys ?^={4,}<ret><a-x>
} catch %{
# select theirs marker
execute-keys /^={4,}<ret><a-x>
}
# extend to end marker
execute-keys ?^<gt>{4,}<ret><a-x>d
}
} -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
execute-keys ?^[|]{4,}<ret><a-x>d
# select theirs marker
execute-keys /^={4,}<ret>
# extend to end marker
execute-keys ?^<gt>{4,}<ret><a-x>d
}
} -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
execute-keys /^<gt>{4,}<ret><a-x>d
}
} -docstring "merge using new"

View file

@ -22,6 +22,7 @@ in {
./kak/keys.kak
./kak/plug.kak
./kak/usermode.kak
./kak/git-mode.kak
]) + ''
set global scrolloff 10,20