blob: 1b58a6e78ea902f30e4eefaef3f0f5c11b1e6ecd (
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
define-command gitui -params .. %{
terminal-singleton git \
env "GIT_EDITOR=kak -c %val{session}" \
'EDITOR=kcr edit' \
'VISUAL=kcr edit' \
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 m ': git-line-blame<ret>' -docstring 'Blame selection lines'
map global git M ': git-file-blame<ret>' -docstring 'Blame buffer file'
map global git l ': git-link<ret>' -docstring 'Open remote link to selection in file'
# diff
declare-user-mode git-d
map global git d ': enter-user-mode git-d<ret>' -docstring 'Diff mode'
map global git-d d ': git-open-diff<ret>' -docstring 'Open staged files'
map global git-d c ': git-open-commit<ret>' -docstring 'Open files changed in last commit'
map global git-d x ': git-grep-conflict-markers<ret>' -docstring 'Find conflicts'
define-command git-grep-conflict-markers %{ grep <<<< }
# rebase
declare-user-mode git-r
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'
# Objects
map global object m %{c^[<lt>=]{4\,}[^\n]*\n,^[<gt>=]{4\,}[^\n]*\n<ret>} -docstring 'conflict markers'
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 %{ }
}
define-command git-line-blame %{
terminal-singleton git-blame sh -c \
"git -p log -u -L '%sh{echo ""$kak_selection_desc"" | sed -E 's/\.[0-9]+//g'}:%val{buffile}' --color=always | delta"
}
define-command git-file-blame %{
terminal-singleton git-blame gitu blame %val{buffile}
}
define-command git-open-diff -params 0..1 %{
eval %sh{ git diff --name-only "${1:-HEAD}" | sed 's/^/edit /' }
}
define-command git-open-commit -params 0..1 %{
eval %sh{ git show --name-only --pretty="" "$@" | sed 's/^/edit /' }
}
define-command git-link %{
eval %sh{
line_start=${kak_selection_desc%%.*}
tmp=${kak_selection_desc#*,}
line_end=${tmp%%.*}
link=$("$kak_config/scripts/git.clj" link "$kak_buffile" "$line_start" "$line_end")
xdg-open "$link" || true >/dev/null
echo "info '$link'"
}
}
|