From 6d314810e9a84c9e575e208c68135ecbbac4388c Mon Sep 17 00:00:00 2001 From: Andre Ramnitz Date: Thu, 28 Dec 2023 17:32:48 +0100 Subject: [PATCH] kak: clean-up config --- config/kak/kakrc | 125 +++++++++++++++++++---------------------------- 1 file changed, 51 insertions(+), 74 deletions(-) diff --git a/config/kak/kakrc b/config/kak/kakrc index 8a0e1943..33fc27a3 100644 --- a/config/kak/kakrc +++ b/config/kak/kakrc @@ -4,6 +4,42 @@ hook global NormalKey y %{ nop %sh{ printf %s "$kak_main_reg_dquote" | wl-copy > /dev/null 2>&1 & }} + +# run on file open +# ────────────────────────────────────────────────────────────────────────────── +hook global BufOpenFile .* %{ + modeline-parse +} + +hook global BufCreate [^*].* %{ + nop %sh{ + mru=~/.cache/kak-mru + echo "$kak_buffile" | awk '!seen[$0]++' - "$mru" | sponge "$mru" + } +} + + +# dynamic scrolloff +# ────────────────────────────────────────────────────────────────────────────── +hook global WinCreate [^*].* %{ + editorconfig-load + hook -once window WinDisplay .* %{ + hook window WinResize [0-9]*\.[0-9]* %{ + set-option window scrolloff %sh{ + printf '%u,%u' "$(($kak_window_height / 5))" "$(($kak_window_width / 8))" + } + } + } +} + + +# session manager +# ────────────────────────────────────────────────────────────────────────────── +evaluate-commands %sh{ + kks init +} + + # Enable PLUGin manager # ────────────────────────────────────────────────────────────────────────────── source "%val{config}/plugins/plug.kak/rc/plug.kak" @@ -49,19 +85,6 @@ set-option global tabstop 4 set-option global indentwidth 4 -# dynamic scrolloff -# ────────────────────────────────────────────────────────────────────────────── -hook global WinCreate [^*].* %{ - hook -once window WinDisplay .* %{ - hook window WinResize [0-9]*\.[0-9]* %{ - set-option window scrolloff %sh{ - printf '%u,%u' "$(($kak_window_height / 5))" "$(($kak_window_width / 8))" - } - } - } -} - - # Different Cursor color in insert mode # ────────────────────────────────────────────────────────────────────────────── # Shades of blue/cyan for normal mode @@ -93,11 +116,6 @@ hook global ModeChange (push|pop):insert:.* %{ } -# Enable editor config -# ────────────────────────────────────────────────────────────────────────────── -hook global WinCreate ^[^*]+$ %{ editorconfig-load } - - # Extra editor commands # ────────────────────────────────────────────────────────────────────────────── # tab replacement @@ -125,35 +143,42 @@ map global normal '' :comment-block -docstring 'comment block' map global goto m 'm;' -docstring 'matching char' map global normal ': inc %val{count} +' map global normal ': inc %val{count} -' +map global normal q Q +map global normal -docstring 'Next buffer ' ': buffer-next' +map global normal -docstring 'Previous buffer' ': buffer-previous' + # kks mappings # ────────────────────────────────────────────────────────────────────────────── map global normal -docstring 'terminal' ': kks-connect terminal' map global normal -docstring 'files' ': kks-connect terminal-popup kks-files' -map global normal -docstring 'buffers' ': kks-connect terminal-popup kks-buffers' -map global normal -docstring 'buffers' ': kks-connect terminal-popup kks-buffers' +map global normal -docstring 'buffers' q ': kks-connect terminal-popup kks-buffers' map global normal -docstring 'live grep' ': kks-connect terminal-popup kks-grep' map global normal -docstring 'lines in buffer' ': kks-connect terminal-popup kks-lines' map global normal -docstring 'recent files' ': kks-connect terminal-popup kks-mru' map global normal -docstring 'vcs client' ': kks-connect terminal-popup lazygit' map global normal -docstring 'file browser' ': kks-connect terminal-panel kks-lf' + # default user mode # ────────────────────────────────────────────────────────────────────────────── -map global user -docstring 'Buffer mode' b ':enter-user-mode buffermode' -map global user -docstring 'Selection mode' s ':enter-user-mode selectionmode' -map global user -docstring 'edit kakrc' e ': e ~/.config/kak/kakrc' +map global user -docstring 'Buffer mode' b ':enter-user-mode buffermode' +map global user -docstring 'Selection mode' s ':enter-user-mode selectionmode' +map global user -docstring 'edit kakrc' e ': e ~/.config/kak/kakrc' +map global user -docstring 'relative line numbers enable' r ': add-highlighter window/nl number-lines -relative -hlcursor' +map global user -docstring 'relative line numbers disable' R ': remove-highlighter window/nl' + # buffer user mode # ────────────────────────────────────────────────────────────────────────────── declare-user-mode buffermode map global buffermode -docstring 'enable autocomplete' a ': set-option -add buffer autocomplete insert' map global buffermode -docstring 'disable autocomplete' A ': set-option -remove buffer autocomplete insert' +map global buffermode -docstring 'Previous buffer' b ': buffer-previous' +map global buffermode -docstring 'clean tabs and trailing whitespace in the buffer' c ': clean-buffer' +map global buffermode -docstring 'buffer picker' l ': kks-connect terminal-popup kks-buffers' map global buffermode -docstring 'Lint buffer' L ': buffer *lint-output*' -map global buffermode -docstring 'buffer picker' l ': connect terminal-popup kcr fzf buffers' map global buffermode -docstring 'Next buffer ' n ': buffer-next' -map global buffermode -docstring 'Previous buffer' p ': buffer-previous' -map global buffermode -docstring 'clean tabs and trailing whitespace in the buffer' c ': clean-buffer' map global buffermode -docstring 'wrap enable' w ': add-highlighter buffer/bw wrap' map global buffermode -docstring 'wrap disable' W ': remove-highlighter buffer/bw' @@ -163,11 +188,6 @@ map global buffermode -docstring 'wrap disable' W ': remove-highlighter buffer/b declare-user-mode selectionmode map global selectionmode -docstring 'clean tabs and trailing whitespace in selections' c ': clean-selections' -# window user mode -# ────────────────────────────────────────────────────────────────────────────── -declare-user-mode windowmode -map global windowmode -docstring 'relative line numbers enable' r ': add-highlighter window/nl number-lines -relative -hlcursor' -map global windowmode -docstring 'relative line numbers disable' R ': remove-highlighter window/nl' # terminal config (via foot.kak) # ────────────────────────────────────────────────────────────────────────────── @@ -177,46 +197,3 @@ set-option global foot_normal_flags '' set-option global foot_popup_flags '-a kakpopup' set-option global foot_panel_cmd 'foot' - -# run on file open -# ────────────────────────────────────────────────────────────────────────────── -hook global BufOpenFile .* %{ - modeline-parse -} - -# session manager -# ────────────────────────────────────────────────────────────────────────────── -evaluate-commands %sh{ - kks init -} - - -# Reload kakrc and .kak when saving. -# ────────────────────────────────────────────────────────────────────────────── -# Adds -override to definitions (unless they seem to be python defs!) -# Evals provide module directly - -def resource -params 1 %{ - eval %sh{ - file=$(dirname "$1")/.reload.kak - cat "$1" | - sed 's/^def \([^:]*\)$/def -override \1/' | - sed 's/^define-command /def -override /' | - sed 's/^addhl /addhl -override/' | - sed 's/^add-highlighter /addhl -override /' | - sed 's/^provide-module \w\+ /eval /' | - cat > "$file" - printf %s " - source $file - nop %sh{ - rm $file - } - " - } - echo Reloaded %arg{1} -} - -rmhooks global reload-kak -hook -group reload-kak global BufWritePost (.*kakrc|.*\.kak) %{ - resource %val{hook_param} -} -- 2.51.2