summaryrefslogtreecommitdiff
path: root/kak/kakrc
blob: ea2014218f0eb2b8b5534c36dd8d7317ab6bbf90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
colorscheme plain
add-highlighter global/ number-lines -hlcursor -relative

set-option global ui_options terminal_status_on_top=true
set-option -add global ui_options terminal_assistant=clippy
set-option global tabstop 4

# 0 -> tabs for indentation
set-option global indentwidth 0
set-option global scrolloff 3,3

# default error pattern checks for error or fatal after the error location
# this makes it just look for the location, which makes it more generic for
# other compilers to *just* work. works for all the compilers i care about
# for now: gcc/clang/cproc, go, odin
set-option global make_error_pattern '^([^:\n]+)[:\(](\d+):(?:(\d+))?[:\)]?'

hook global ModuleLoaded x11 %{
	set global termcmd 'st -e sh -c'
	map -docstring 'yank to system clipboard' global user y '<a-|>xclip -selection clipboard<ret>'
	map -docstring 'paste from system clipboard' global user p '<!>xclip -selection clipboard -o<ret>'
}

hook global ModuleLoaded wayland %{
	set global termcmd 'foot -e sh -c'
	map -docstring 'yank to system clipboard' global user y '<a-|>wl-copy<ret>'
	map -docstring 'paste from system clipboard' global user p '<!>wl-paste<ret>'
}

hook global ModuleLoaded tmux %{
	set global windowing_placement 'horizontal'
	evaluate-commands %sh{
		copy_cmd="wl-copy"
		paste_cmd="wl-paste"
		if [ -z "$WAYLAND_DISPLAY" ]; then
			copy_cmd="xclip -selection clipboard"
			paste_cmd="xclip -selection clipboard -o"
		fi
		printf "map -docstring 'yank to system clipboard' global user y '<a-|>%s<ret>'\n" "$copy_cmd"
		printf "map -docstring 'paste from system clipboard' global user p '<!>%s<ret>'\n" "$paste_cmd"
	}
}

hook global BufWritePre .* %{
	jrk-trim-trailing-whitespace
}

define-command jrk-set-makecmd-and-make %{
    prompt -file-completion 'makecmd: ' %{
        evaluate-commands %{
            set-option global makecmd %val{text}
            jrk-save-and-make
        }
    }
}

define-command jrk-save-and-make %{
	evaluate-commands %sh{
		[ "$kak_bufname" != "*make*" ] && printf "evaluate-commands %%{ write\nmake }\n"
	}
}

define-command jrk-trim-trailing-whitespace %{
	try %{ execute-keys -draft "%%s\h+$<ret>d" }
}

map -docstring 'goto next make error' global user [ '<:>make-next-error<ret>'
map -docstring 'goto previous make error' global user ] '<:>make-previous-error<ret>'

map -docstring 'save file and run make' global user q '<:>jrk-save-and-make<ret>'
map -docstring 'set makecmd and make' global user Q '<:>jrk-set-makecmd-and-make<ret>'

map -docstring 'edit file' global user . '<:>edit '
map -docstring 'open buffer' global user , '<:>buffer '

map -docstring 'write file' global user w '<:>w<ret>'

# colemak dh binds
map global normal n "h"
map global normal N "H"
map global normal e "j"
map global normal E "J"
map global normal i "k"
map global normal I "K"
map global normal o "l"
map global normal O "L"

map global normal j "e"
map global normal J "E"
map global normal k "n"
map global normal K "N"
map global normal h "o"
map global normal H "O"
map global normal l "i"
map global normal L "I"

map global normal <a-n> <a-h>
map global normal <a-o> <a-l>
map global normal <a-k> <a-n>