diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-10-13 14:13:52 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-10-21 13:39:45 +0530 |
| commit | 38dc33178ed1ec08277782dba40c4fa55c07287c (patch) | |
| tree | 6b1b17dc67fe8a82182357ab080d74c1409055bc | |
| parent | 043f497d7475860f49815c9de35c0c76aa45a135 (diff) | |
| download | kakoune-config-38dc33178ed1ec08277782dba40c4fa55c07287c.tar.gz kakoune-config-38dc33178ed1ec08277782dba40c4fa55c07287c.zip | |
Refactor some bits out
| -rw-r--r-- | autoload/+init.kak | 44 | ||||
| -rw-r--r-- | autoload/files.kak | 22 | ||||
| -rw-r--r-- | autoload/git.kak | 61 | ||||
| -rw-r--r-- | colors/phenax.kak | 4 |
4 files changed, 89 insertions, 42 deletions
diff --git a/autoload/+init.kak b/autoload/+init.kak index 5e99424..d2a4233 100644 --- a/autoload/+init.kak +++ b/autoload/+init.kak @@ -28,11 +28,13 @@ add-highlighter global/ line '%val{cursor_line}' RowLine add-highlighter global/ regex \h+$ 0:Error # Highlight trailing whitespaces add-highlighter global/ wrap -word -indent # Softwrap long lines add-highlighter global/ show-matching -previous -# add-highlighter global/search dynregex '%reg{/}' 0:search + +# Search hook global RegisterModified '/' %{ add-highlighter -override global/search regex "%reg{/}" 0:search } map global user '<esc>' ':set-register slash ""<ret>' map global user '/' '/(?i)' +# Preserve count for user modes (look for alternatives) # TODO: Reset count on modechange? declare-option -hidden int user_mode_count 0 define-command enter-user-mode-with-count -params 1 %{ @@ -51,44 +53,6 @@ hook global ModeChange .*:insert:.* %{ try %{ unset-face window PrimaryCursorEol } } -# File/buffer management -def find -docstring "find files" -menu -params 1 %{ edit -existing %arg{1} } \ - -shell-script-candidates %{ fd -t f --hidden --color=never -E .git } -set-option global grepcmd "rg -S --vimgrep --hidden -g '!**/.git/**'" - -def file-manager -params .. %{ connect terminal env "EDITOR=kcr edit" daffm -c @kak %arg{@} } - -declare-user-mode buffer -map global user b ':enter-user-mode buffer<ret>' -docstring 'Buffer mode' -map global buffer b ':buffer ' -docstring 'Switch buffer' -map global buffer d ':delete-buffer<ret>' -docstring 'Delete buffer' -map global buffer s ':write<ret>' -docstring 'Save' - -declare-user-mode file -map global user f ':enter-user-mode file<ret>' -docstring 'File mode' -map global file f ':find ' -docstring 'Find files' -map global file g ':grep ' -docstring 'Grep' -map global file n ':file-manager %val{buffile}<ret>' -docstring 'File manager' - -# TODO: Proper mappings for next/prev on results -hook global -always BufOpenFifo '\*grep\*' %{ map global normal <minus> ': grep-next-match<ret>' } -hook global -always BufOpenFifo '\*make\*' %{ map global normal <minus> ': make-next-error<ret>' } - -# Git -def gitui -params .. %{ connect terminal env "EDITOR=kcr edit" gitu %arg{@} } - -declare-user-mode git -map global user g ':enter-user-mode git<ret>' -docstring 'Git mode' -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 s ':gitui<ret>' -docstring 'Git status UI' -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 ModeChange .*:.*:normal %{ try %{git show-diff} } -# hook global -group git-diff WinCreate .* %{ try %{git show-diff} } - # Tmux window mode declare-user-mode win map global normal <c-w> ':enter-user-mode win<ret>' -docstring 'Window mode' @@ -111,7 +75,7 @@ def casecamel %{ exec '`s[-_<space>]<ret>d~<a-i>w' } def casesnake %{ exec '<a-:><a-;>s-|[a-z][A-Z]<ret>;a<space><esc>s[-\s]+<ret>c_<esc><a-i>w`' } def casekebab %{ exec '<a-:><a-;>s_|[a-z][A-Z]<ret>;a<space><esc>s[_\s]+<ret>c-<esc><a-i>w`' } map global code <a-k> :casekebab<ret> -docstring 'kebab-casing' -map global code <a-s> :casesnake<ret> -docstring 'snake_casing' +map global code <a-_> :casesnake<ret> -docstring 'snake_casing' map global code <a-c> :casecamel<ret> -docstring 'camelCasing' map global normal <c-j> 15j diff --git a/autoload/files.kak b/autoload/files.kak new file mode 100644 index 0000000..3f5d7b1 --- /dev/null +++ b/autoload/files.kak @@ -0,0 +1,22 @@ +set-option global grepcmd "rg -S --vimgrep --hidden -g '!**/.git/**'" + +def find -docstring "find files" -menu -params 1 %{ edit -existing %arg{1} } \ + -shell-script-candidates %{ fd -t f --hidden --color=never -E .git } + +def file-manager -params .. %{ connect terminal env "EDITOR=kcr edit" daffm -c @kak %arg{@} } + +declare-user-mode buffer +map global user b ':enter-user-mode buffer<ret>' -docstring 'Buffer mode' +map global buffer b ':buffer ' -docstring 'Switch buffer' +map global buffer d ':delete-buffer<ret>' -docstring 'Delete buffer' +map global buffer s ':write<ret>' -docstring 'Save' + +declare-user-mode file +map global user f ':enter-user-mode file<ret>' -docstring 'File mode' +map global file f ':find ' -docstring 'Find files' +map global file g ':grep ' -docstring 'Grep' +map global file n ':file-manager %val{buffile}<ret>' -docstring 'File manager' + +# TODO: Proper mappings for next/prev on results +hook global -always BufOpenFifo '\*grep\*' %{ map global normal <minus> ': grep-next-match<ret>' } +hook global -always BufOpenFifo '\*make\*' %{ map global normal <minus> ': make-next-error<ret>' } 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<ret>' -docstring 'Git mode' +map global git s ':gitu<ret>' -docstring 'Gitu 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' + +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<ret>' -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<ret>' +# map window normal q ': delete-buffer %val{buffile}<ret>' + +# map window user l ': enter-user-mode git-status-log<ret>' +# map window git-status-log l ': git log --oneline<ret>' +# map window normal d 'x: git-eval-status-line<ret>: git diff -- %opt{git_file}' + +# map window normal c ': enter-user-mode git-status-commit<ret>' +# map window git-status-commit c ': git commit<ret>' +# map window git-status-commit a ': git commit --amend<ret>' +# } + +# hook -group git-log global WinSetOption filetype=git-log %{ +# set-option buffer readonly true +# map window normal q ': git status -bs<ret>' +# } + +# hook -group git-diff global WinSetOption filetype=git-diff %{ +# set-option buffer readonly true +# map window normal q ': git status -bs<ret>' +# } diff --git a/colors/phenax.kak b/colors/phenax.kak index ea985d8..2501e23 100644 --- a/colors/phenax.kak +++ b/colors/phenax.kak @@ -1,6 +1,6 @@ evaluate-commands %sh{ foreground="rgb:c5c8c6" - foreground2="rgb:809090" + foreground2="rgb:90a0a0" background="default" accent1="rgb:007070" accent2="rgb:009090" @@ -72,7 +72,7 @@ evaluate-commands %sh{ face global LineNumbers ${linenr_fg},${linenr_bg} face global LineNumberCursor ${linenr_fg_cur},${linenr_bg}+b face global LineNumbersWrapped ${mildhighlight},${linenr_bg}+b - face global MenuForeground ${menu},${foreground} + face global MenuForeground ${background},${accent1} face global MenuBackground ${foreground},${menu} face global MenuInfo ${red} face global Information ${foreground2},${background} |
