From 9e737da231b7726d9472aa0753833aa93fc92346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Eug=C3=AAnio?= Date: Tue, 6 Dec 2022 21:16:39 -0300 Subject: [PATCH] extract git mode to separate file --- user/kak/git-mode.kak | 64 +++++++++++++++++++++++++++++++++++++++++++ user/kak/kakrc | 1 + user/kak/usermode.kak | 61 ----------------------------------------- user/kakoune.nix | 1 + 4 files changed, 66 insertions(+), 61 deletions(-) create mode 100644 user/kak/git-mode.kak diff --git a/user/kak/git-mode.kak b/user/kak/git-mode.kak new file mode 100644 index 0000000..b59cc7b --- /dev/null +++ b/user/kak/git-mode.kak @@ -0,0 +1,64 @@ +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' +map global git 's' ': git status' -docstring 'status' +map global git 'S' '_: git show %val{selection} --' -docstring 'show' +map global git 'a' ': git add' -docstring 'add current' +map global git 'd' ': git diff %reg{%}' -docstring 'diff current' +map global git 'r' ': git checkout %reg{%}' -docstring 'restore current' +map global git 'A' ': git add --all' -docstring 'add all' +map global git 'D' ': git diff' -docstring 'diff all' +map global git '' ': git diff --staged' -docstring 'diff staged' +map global git 'c' ': git commit -v' -docstring 'commit' +map global git 'u' ': git update-diff' -docstring 'update gutter diff' +map global git 'n' ': git next-hunk ' -docstring 'next hunk' +map global git 'p' ': git prev-hunk ' -docstring 'previous hunk' +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-original ' -docstring 'merge using original' + +define-command -override git-merge-head %{ + evaluate-commands -draft %{ + # delete head marker + execute-keys ^{4,}d + try %{ + # select original marker + execute-keys /^[|]{4,} + # extend to theirs marker + execute-keys ?^={4,} + } catch %{ + # select theirs marker + execute-keys /^={4,} + } + # extend to end marker + execute-keys ?^{4,}d + } +} -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,}d + # select theirs marker + execute-keys /^={4,} + # extend to end marker + execute-keys ?^{4,}d + } +} -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,}d + } +} -docstring "merge using new" diff --git a/user/kak/kakrc b/user/kak/kakrc index 4b38e3c..d80b6de 100644 --- a/user/kak/kakrc +++ b/user/kak/kakrc @@ -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" diff --git a/user/kak/usermode.kak b/user/kak/usermode.kak index 01d3bbd..875dfc2 100644 --- a/user/kak/usermode.kak +++ b/user/kak/usermode.kak @@ -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' -docstring 'switch buffer' map global user 'l' ': lsp-enable-decals' -docstring 'LSP enable decals' map global user 'L' ': lsp-disable-decals' -docstring 'LSP disable decals' -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' -map global git 's' ': git status' -docstring 'status' -map global git 'S' '_: git show %val{selection} --' -docstring 'show' -map global git 'a' ': git add' -docstring 'add current' -map global git 'd' ': git diff %reg{%}' -docstring 'diff current' -map global git 'r' ': git checkout %reg{%}' -docstring 'restore current' -map global git 'A' ': git add --all' -docstring 'add all' -map global git 'D' ': git diff' -docstring 'diff all' -map global git '' ': git diff --staged' -docstring 'diff staged' -map global git 'c' ': git commit -v' -docstring 'commit' -map global git 'u' ': git update-diff' -docstring 'update gutter diff' -map global git 'n' ': git next-hunk ' -docstring 'next hunk' -map global git 'p' ': git prev-hunk ' -docstring 'previous hunk' -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-original ' -docstring 'merge using original' - map global user 'f' ': enter-user-mode find' -docstring 'find mode' map global find 't' ': tree' -docstring 'file tree' map global find 'f' ': find_file' -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 ^{4,}d - try %{ - # select original marker - execute-keys /^[|]{4,} - # extend to theirs marker - execute-keys ?^={4,} - } catch %{ - # select theirs marker - execute-keys /^={4,} - } - # extend to end marker - execute-keys ?^{4,}d - } -} -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,}d - # select theirs marker - execute-keys /^={4,} - # extend to end marker - execute-keys ?^{4,}d - } -} -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,}d - } -} -docstring "merge using new" diff --git a/user/kakoune.nix b/user/kakoune.nix index 40c7aa9..6405d82 100644 --- a/user/kakoune.nix +++ b/user/kakoune.nix @@ -22,6 +22,7 @@ in { ./kak/keys.kak ./kak/plug.kak ./kak/usermode.kak + ./kak/git-mode.kak ]) + '' set global scrolloff 10,20