aboutsummaryrefslogtreecommitdiff
path: root/autoload/git.kak
blob: e0db3c441aa5a1662a6f7af7634bed4af041a6a4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
define-command gitui -params .. %{
  connect terminal env "EDITOR=kak -c %val{session}" "VISUAL=kak -c %val{session}" gitu %arg{@}
}

declare-user-mode git
declare-user-mode git-r
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 git r ': enter-user-mode git-r<ret>' -docstring 'Git re(base/set) mode'
map global git-r f ': git reset HEAD^1 -- %val{buffile}<ret>' -docstring 'Split file out of last 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 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 } catch %{ }
}

# TODO: Toggle this
# hook global -group git-diff-if-repo EnterDirectory .* %{
#   remove-hooks global git-diff
#   try %{
#     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
#     }
#   }
# }