repos / dotfiles

my dotfiles

dotfiles / dot_config / kak
Eric Bower  ·  2026-01-16

kakrc

 1colorscheme tomorrow-night
 2
 3set-option global autoreload true
 4set-option global grepcmd 'rg -n'
 5set-option global tabstop 2
 6set-option global indentwidth 0
 7set-option global ui_options terminal_assistant=none # disable clippy
 8set-option global scrolloff 3,3
 9
10define-command find -docstring "find files" -params 1 %{ edit %arg{1} }
11complete-command find shell-script-candidates %{ fd -t f }
12
13define-command dowrap %{ # soft-wrap command
14	add-highlighter buffer/ wrap -indent -word -marker ""
15	map buffer normal j gd
16	map buffer normal k gu
17}
18
19define-command copy-to-osc %{
20	nop %sh{
21		encoded=$(printf %s "$kak_selections" | base64 | tr -d '\n')
22		printf "\e]52;;%s\e\\" "$encoded" >/dev/tty
23	}
24	echo "Copied selections to OSC52 clipboard"
25}
26
27map global user y ':copy-to-osc<ret>' -docstring 'Copy to OSC52 clipboard'
28
29define-command copy-github-permalink %{
30    evaluate-commands %sh{
31        file=$(printf "%s" "$kak_buffile" | sed "s|^$(pwd)/||")
32        line="$kak_cursor_line"
33        github_remote=$(git config --get-regexp '^remote\..*\.url' | grep github.com | head -1 | awk '{print $2}')
34        if [[ -z "$github_remote" ]]; then
35            printf "echo 'error: No github remote found'"
36        else
37            remote=$(echo "$github_remote" | sed 's|^.*://||;s|^git@||;s|:|/|;s|\.git$||')
38            commit=$(git rev-parse HEAD)
39            url="https://$remote/blob/$commit/$file#L$line"
40            encoded=$(printf %s "$url" | base64 | tr -d '\n')
41            printf "set-register '\"' '%s'\n" "$url"
42            printf "nop %%sh{ printf '\\e]52;;%s\\e\\\\' '%s' >/dev/tty }\n" "$encoded"
43            printf "echo 'Copied github permalink to clipboard'"
44        fi
45    }
46}
47
48map global user u ':copy-github-permalink<ret>' -docstring 'Copy github permalink'
49
50hook global WinCreate .* %{
51	addhl window/ column 100 default,rgb:404040
52}
53add-highlighter global/ show-matching
54
55eval %sh{kak-lsp}
56hook global WinSetOption filetype=(python|go|javascript|typescript|zls) %{
57	lsp-enable-window
58}
59set-option global modelinefmt "%opt{lsp_modeline} %opt{modelinefmt}"
60
61map global user l ':enter-user-mode lsp<ret>' -docstring 'LSP mode'
62map global user h <esc>:lsp-hover<ret> -docstring 'LSP hover'
63
64map global insert <tab> '<a-;>:try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks <lt>tab> }<ret>' -docstring 'Select next snippet placeholder'
65
66map global object a '<a-semicolon>lsp-object<ret>' -docstring 'LSP any symbol'
67map global object f '<a-semicolon>lsp-object Function Method<ret>' -docstring 'LSP function or method'
68map global object d '<a-semicolon>lsp-diagnostic-object error warning<ret>' -docstring 'LSP errors and warnings'
69map global object D '<a-semicolon>lsp-diagnostic-object error<ret>' -docstring 'LSP errors'
70
71map global user f ': find<space>' -docstring "find file"
72map global user g ': grep<space>' -docstring "grep project dir"
73map global user q ': delete-buffer<ret>' -docstring "close buffer"
74map global user b ': buffer ' -docstring "buffer list"