From 5d9a6f0f97d5e0d451a56a94e6e6616b4c8c3a40 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Mon, 13 Oct 2025 20:37:17 +0530 Subject: Add repl integration --- autoload/git.kak | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'autoload/git.kak') 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' -docstring 'Git mode' -map global git s ':gitui' -docstring 'Git tui' -map global git A ':git add %val{buffile}' -docstring 'Add file' -map global git c ':git add commit' -docstring 'Commit' -map global git C ':git add commit --amend' -docstring 'Amend commit' +map global user g ': enter-user-mode git' -docstring 'Git mode' +map global git s ': gitui' -docstring 'Git tui' +map global git A ': git add %val{buffile}' -docstring 'Add file' +map global git c ': git add commit' -docstring 'Commit' +map global git C ': git add commit --amend' -docstring 'Amend commit' # Hunk -map global git n ':git next-hunk' -docstring 'Next hunk' -map global git p ':git prev-hunk' -docstring 'Previous hunk' +map global git n ': git next-hunk' -docstring 'Next hunk' +map global git p ': git prev-hunk' -docstring 'Previous hunk' +map global git h ': git-toggle-diff' -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 -- cgit v1.3.1