diff options
Diffstat (limited to 'autoload/git.kak')
| -rw-r--r-- | autoload/git.kak | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/autoload/git.kak b/autoload/git.kak index 86f6d76..6f4015c 100644 --- a/autoload/git.kak +++ b/autoload/git.kak @@ -1,26 +1,40 @@ -define-command gitui -params .. %{ connect terminal env "EDITOR=kcr edit" gitu %arg{@} } +define-command gitui -params .. %{ + connect terminal env "EDITOR=kak -c %val{session}" "VISUAL=kak -c %val{session}" gitu %arg{@} +} declare-user-mode git -map global user g ':enter-user-mode git<ret>' -docstring 'Git mode' -map global git s ':gitui<ret>' -docstring 'Git tui' -map global git A ':git add %val{buffile}<ret>' -docstring 'Add file' -map global git c ':git add commit<ret>' -docstring 'Commit' -map global git C ':git add commit --amend<ret>' -docstring 'Amend commit' +map global user g ': enter-user-mode git<ret>' -docstring 'Git mode' +map global git s ': gitui<ret>' -docstring 'Git tui' +map global git A ': git add %val{buffile}<ret>' -docstring 'Add file' +map global git c ': git add commit<ret>' -docstring 'Commit' +map global git C ': git add commit --amend<ret>' -docstring 'Amend commit' # Hunk -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 n ': git next-hunk<ret>' -docstring 'Next hunk' +map global git p ': git prev-hunk<ret>' -docstring 'Previous hunk' +map global git h ': git-toggle-diff<ret>' -docstring 'Toggle hunk indicators' set-option global git_diff_add_char "+" set-option global git_diff_del_char "-" set-option global git_diff_mod_char "~" set-option global git_diff_top_char "^" +define-command git-toggle-diff %{ + try %{ remove-highlighter window/git-diff } catch %{ git show-diff } +} + +# TODO: Toggle this hook global -group git-diff-if-repo EnterDirectory .* %{ - # TODO: Disable git hunk highlight for non-git repos remove-hooks global git-diff - hook global -group git-diff ModeChange .*:.*:normal %{ try %{git show-diff} } - hook global -group git-diff WinCreate .* %{ try %{git show-diff} } + evaluate-commands %sh{ + if (git rev-parse --is-inside-work-tree >/dev/null 2>&1); then + echo " + hook global -group git-diff ModeChange .*:.*:normal %{ try %{git update-diff} } + hook global -group git-diff WinCreate .* %{ try %{git update-diff} } + hook global -group git-diff BufReload .* %{ try %{git update-diff} } + " + fi + } } # Git window actions |
