From 38dc33178ed1ec08277782dba40c4fa55c07287c Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Mon, 13 Oct 2025 14:13:52 +0530 Subject: Refactor some bits out --- autoload/git.kak | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 autoload/git.kak (limited to 'autoload/git.kak') diff --git a/autoload/git.kak b/autoload/git.kak new file mode 100644 index 0000000..90e5f75 --- /dev/null +++ b/autoload/git.kak @@ -0,0 +1,61 @@ +define-command gitui -params .. %{ connect terminal env "EDITOR=kcr edit" gitu %arg{@} } + +declare-user-mode git +map global user g ':enter-user-mode git' -docstring 'Git mode' +map global git s ':gitu' -docstring 'Gitu 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' + +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 "^" + +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} } +} + +# Git window actions + +# declare-option -hidden str git_file +# define-command -hidden git-eval-status-line %{ +# evaluate-commands %sh{ +# file=$(echo "$kak_selection" | sed 's/^\s*[A-Z?]\+\s\+//') +# echo "set-option window git_file '$file'" +# } +# } + +# declare-user-mode git-status-commit +# declare-user-mode git-status-log +# map global git s ':git status -bs' -docstring 'Git status UI' +# hook -group git-status global WinSetOption filetype=git-status %{ +# set-option buffer readonly true +# map window normal R ':git status -bs' +# map window normal q ': delete-buffer %val{buffile}' + +# map window user l ': enter-user-mode git-status-log' +# map window git-status-log l ': git log --oneline' +# map window normal d 'x: git-eval-status-line: git diff -- %opt{git_file}' + +# map window normal c ': enter-user-mode git-status-commit' +# map window git-status-commit c ': git commit' +# map window git-status-commit a ': git commit --amend' +# } + +# hook -group git-log global WinSetOption filetype=git-log %{ +# set-option buffer readonly true +# map window normal q ': git status -bs' +# } + +# hook -group git-diff global WinSetOption filetype=git-diff %{ +# set-option buffer readonly true +# map window normal q ': git status -bs' +# } -- cgit v1.3.1