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