# Link builtin autoloads nop %sh{ rm -f "$kak_config/autoload/standard-library" || true rm -f "$kak_config/autoload/plugins" || true ln -sf "$kak_runtime/rc" "$kak_config/autoload/standard-library" 2>/dev/null || true ln -sf "$kak_runtime/autoload/plugins" "$kak_config/autoload/plugins" 2>/dev/null || true } # Disable indent trimming set-option global disabled_hooks .*-trim-indent eval %sh{kak-tree-sitter -dksvv --init "${kak_session}" --with-highlighting --with-text-objects} eval %sh{kcr init kakoune} colorscheme phenax set-option global autoreload yes set-option global incsearch true set-option global indentwidth 2 set-option global tabstop 2 set-option -add global path "**" set-option global startup_info_version 20250603 set-option global scrolloff 10,3 set-option -add global ui_options terminal_enable_mouse=false terminal_set_title=true # terminal_status_on_top=true # Modeline # declare-option -hidden _lsp_modeline_diagnostics "%opt{lsp_diagnostic_error_count}" # %opt{lsp_modeline_breadcrumbs} set-option global modelinefmt \ '{StatusLineExtras}%opt{lsp_modeline_progress} {StatusLineDetails}{{context_info}} {{mode_info}} %val{cursor_line}/%val{buf_line_count}:%val{cursor_char_column} {StatusLineBufname}%sh{echo "$kak_bufname" | awk -F/ "{if (NF >= 2) {print \$(NF-1) \"/\" \$NF} else {print \$NF}}"}' # Highlighters add-highlighter global/ number-lines -relative -hlcursor -min-digits 3 -separator ' ' add-highlighter global/ column '%val{cursor_char_column}' ColumnLine add-highlighter global/ line '%val{cursor_line}' RowLine add-highlighter global/ regex \h+$ 0:Error # Highlight trailing whitespaces add-highlighter global/ show-matching -previous add-highlighter global/ show-whitespaces -spc ' ' -tab '│' -lf '¬' -indent '│' hook global RegisterModified '/' %{ # Highlight search add-highlighter -override global/search regex "%reg{/}" 0:search } add-highlighter global/ regex \b(TODO|FIXME)\b 0:default+rb add-highlighter global/ regex @(todo|fixme) 0:default+rb # Misc keys map global user '' ': set-register slash ""' -docstring 'Clear search highlighting' map global normal '/' '/(?i)' # Remap / to case-insensitive search map global user '/' '/' map global user s ': w' -docstring 'Save' map global normal 15j -docstring '15 down' map global normal 15k -docstring '15 up' map global user y " xclip -selection clipboard" -docstring "yank the selection into the clipboard" declare-user-mode system map global user q ': enter-user-mode system' -docstring 'System mode' map global system o ':info %opt{}' -docstring 'Print opt' map global system v ':info %val{}' -docstring 'Print value' map global system d ': buffer *debug*' -docstring 'Switch to debug buffer' map global system f ':set buffer filetype ' -docstring 'Set filetype' map global system M ':set buffer makecmd ""' -docstring 'Set compile command' map global system m ': make' -docstring 'Compile' map global system p ': info %val{buffile}' -docstring 'Print file path' map global system ! ':info %sh{}' -docstring 'Run command' map global system t ': terminal %sh{ echo "$SHELL" }' -docstring 'Open new term' # Wrapping set-option global autowrap_column 100 hook global WinSetOption filetype=git-commit %{ set window autowrap_column 72 autowrap-enable } add-highlighter global/ column '%opt{autowrap_column}' WrapLine add-highlighter global/ wrap -word -indent # Softwrap long lines map global normal = '|fmt -w $kak_opt_autowrap_column' -docstring 'Wrap text with fmt' # 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 %{ set-option window user_mode_count %val{count} enter-user-mode %arg{1} } # Code mode declare-user-mode code map global user c ': enter-user-mode code' -docstring 'Code mode' map global code c ': comment-line' -docstring 'Comment/uncomment lines' map global code f ': apply-formatting' -docstring 'Apply configured formatter' 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 ': casecamel' -docstring 'camelCasing' declare-user-mode ai map global code a ': enter-user-mode ai' -docstring 'AI' map global ai ! '!ai ""' -docstring 'Insert output' map global ai | '|ai ""' -docstring 'Replace output' # Editorconfig hook global WinCreate ^[^*]+$ %{ editorconfig-load }