Eric Bower
·
2026-06-27
1colorscheme gruvbox-dark
2
3face global Information default,rgb:504945
4face global PrimarySelection default,rgb:458588
5set-option global autoreload true
6set-option global grepcmd 'rg -n'
7set-option global ui_options terminal_assistant=none # disable clippy
8set-option global scrolloff 3,3
9
10hook global BufOpenFile .* %{ modeline-parse }
11hook global BufOpenFile .* editorconfig-load
12hook global BufNewFile .* editorconfig-load
13hook global WinCreate .* %{
14 addhl window/ column 80 default,rgb:404040
15 addhl window/ column 100 default,rgb:404040
16}
17add-highlighter global/ show-matching
18
19map global user y ":copy-to-osc<ret>" -docstring "copy selection to OSC52 clipboard"
20map global user u ":copy-github-permalink<ret>" -docstring "copy github permalink"
21map global user t ":copy-filename-to-osc<ret>" -docstring "copy filename to OSC52 clipboard"
22map global user f ":find<space>" -docstring "find file"
23map global user g ":grep<space>" -docstring "grep project directory"
24map global user q ":delete-buffer<ret>" -docstring "close buffer"
25map global user b ":buffer<space>" -docstring "buffer list"
26map global user B ":delete-buffer-picker<ret>" -docstring "delete buffer"
27
28define-command find -docstring "find files" -params 1 %{ edit %arg{1} }
29# complete-command find shell-script-candidates %{ fd -t f }
30complete-command find shell-script-candidates %{
31 find . -type d \
32 \( -name .git -o -name .jj \
33 -o -name .zig-cache -o -name zig-pkg -o -name zig-out \
34 -o -name node_modules \
35 -o -name __pycache__ -o -name .mypy_cache \
36 -o -name .pytest_cache -o -name .ruff_cache -o -name .venv \
37 \) -prune \
38 -o -type f -print | sed 's|^\./||'
39}
40
41define-command dowrap %{ # soft-wrap command
42 add-highlighter buffer/ wrap -indent -word -marker "… "
43 map buffer normal j gd
44 map buffer normal k gu
45}
46
47define-command copy-to-osc %{
48 nop %sh{
49 encoded=$(printf %s "$kak_selections" | base64 | tr -d '\n')
50 printf "\e]52;;%s\e\\" "$encoded" >/dev/tty
51 }
52 echo "Copied selections to OSC52 clipboard"
53}
54
55define-command copy-filename-to-osc %{
56 nop %sh{
57 encoded=$(printf "%s" "$kak_buffile" | sed "s|^$(pwd)/||" | base64 | tr -d '\n')
58 printf "\e]52;;%s\e\\" "$encoded" >/dev/tty
59 }
60 echo "Copied filename to OSC52 clipboard"
61}
62
63define-command copy-github-permalink %{
64 evaluate-commands %sh{
65 file=$(printf "%s" "$kak_buffile" | sed "s|^$(pwd)/||")
66 line="$kak_cursor_line"
67 github_remote=$(git config --get-regexp '^remote\..*\.url' | grep github.com | head -1 | awk '{print $2}')
68 if [[ -z "$github_remote" ]]; then
69 printf "echo 'error: No github remote found'"
70 else
71 remote=$(echo "$github_remote" | sed 's|^.*://||;s|^git@||;s|:|/|;s|\.git$||')
72 commit=$(git rev-parse HEAD)
73 url="https://$remote/blob/$commit/$file#L$line"
74 encoded=$(printf %s "$url" | base64 | tr -d '\n')
75 printf "set-register '\"' '%s'\n" "$url"
76 printf "nop %%sh{ printf '\\e]52;;%s\\e\\\\' '%s' >/dev/tty }\n" "$encoded"
77 printf "echo 'Copied github permalink to clipboard'"
78 fi
79 }
80}
81
82define-command delete-buffer-picker %{
83 prompt -menu -buffer-completion 'delete buffer:' %{
84 delete-buffer %val{text}
85 }
86}
87
88evaluate-commands %sh{
89 if command -V kak-lsp >/dev/null 2>/dev/null ; then
90 kak-lsp --kakoune -s $kak_session
91 echo "
92 set-option global modelinefmt \"%opt{lsp_modeline} %opt{modelinefmt}\"
93 map global user <l> %{: enter-user-mode lsp<ret>} -docstring 'LSP commands'
94 map global insert <tab> '<a-;>:try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks <lt>tab> }<ret>' -docstring 'Select next snippet placeholder'
95 map global object d '<a-semicolon>lsp-diagnostic-object error warning<ret>' -docstring 'LSP errors and warnings'
96 map global object D '<a-semicolon>lsp-diagnostic-object error<ret>' -docstring 'LSP errors'
97
98 hook global BufSetOption filetype=python %{
99 set-option buffer lsp_servers %{
100 [pyright]
101 command = 'pyright-langserver'
102 args = ['--stdio']
103 root_globs = ['pyrightconfig.json', 'pyproject.toml', 'setup.py', 'setup.cfg', 'requirements.txt', 'Pipfile', '.git']
104 }
105 lsp-enable-window
106 }
107 hook global WinSetOption filetype=(python|go|javascript|typescript|zig) %{
108 lsp-enable-window
109 }
110 "
111 else
112 echo "echo -debug kak-lsp not found in PATH"
113 fi
114}