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/+init.kak | 44 ++++---------------------------------------- 1 file changed, 4 insertions(+), 40 deletions(-) (limited to 'autoload/+init.kak') 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 '' ':set-register slash ""' 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' -docstring 'Buffer mode' -map global buffer b ':buffer ' -docstring 'Switch buffer' -map global buffer d ':delete-buffer' -docstring 'Delete buffer' -map global buffer s ':write' -docstring 'Save' - -declare-user-mode file -map global user f ':enter-user-mode file' -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}' -docstring 'File manager' - -# TODO: Proper mappings for next/prev on results -hook global -always BufOpenFifo '\*grep\*' %{ map global normal ': grep-next-match' } -hook global -always BufOpenFifo '\*make\*' %{ map global normal ': make-next-error' } - -# Git -def 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 n ':git next-hunk' -docstring 'Next hunk' -map global git p ':git prev-hunk' -docstring 'Previous hunk' -map global git s ':gitui' -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 ':enter-user-mode win' -docstring 'Window mode' @@ -111,7 +75,7 @@ def casecamel %{ exec '`s[-_]d~w' } def casesnake %{ exec 's-|[a-z][A-Z];as[-\s]+c_w`' } def casekebab %{ exec 's_|[a-z][A-Z];as[_\s]+c-w`' } map global code :casekebab -docstring 'kebab-casing' -map global code :casesnake -docstring 'snake_casing' +map global code :casesnake -docstring 'snake_casing' map global code :casecamel -docstring 'camelCasing' map global normal 15j -- cgit v1.3.1