-
Notifications
You must be signed in to change notification settings - Fork 1
/
kakrc
86 lines (69 loc) · 2.46 KB
/
kakrc
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
##
# Cosmetic stuff
add-highlighter global/ show-matching
add-highlighter global/trailing-whitespace regex '\h+$' 0:Error
colorscheme gruvbox-dark
set-face global InsertCursor default,green+B
hook global ModeChange .*:.*:insert %{
set-face window PrimaryCursor InsertCursor
set-face window PrimaryCursorEol InsertCursor
}
hook global ModeChange .*:insert:.* %{ try %{
unset-face window PrimaryCursor
unset-face window PrimaryCursorEol
} }
hook global WinCreate ^[^*]+$ %{
add-highlighter window/ number-lines -hlcursor
}
hook global RegisterModified '/' %{
add-highlighter -override global/search regex "%reg{/}" 0:+u
}
hook global WinSetOption filetype=markdown %{
add-highlighter window/ wrap -word
}
##
# Insert mode mappings
map global insert <c-left> '<a-;>b'
map global insert <c-right> '<a-;>e'
hook global InsertChar ù %{ try %{
exec -draft hH <a-k>ùù<ret> d
exec -with-hooks <esc>
} }
##
# Normal mode mappings
map global normal '#' :comment-line<ret>
##
# Hooks
hook global ModeChange .*:insert:.* %{ try %{
write
} }
hook global NormalIdle .* %{ try %{
write
} }
##
# Tools
set-option global grepcmd 'rg --vimgrep'
hook global -always BufOpenFifo '\*grep\*' %{ map global user j ':grep-next-match<ret>' }
evaluate-commands %sh{
if [ -n "$SSH_TTY" ]; then
copy='printf "\033]52;;%s\033\\" $(base64 | tr -d "\n") > /dev/tty'
paste='printf "paste unsupported through ssh"'
backend="OSC 52"
else
case $(uname) in
Linux)
if [ -n "$WAYLAND_DISPLAY" ]; then
copy="wl-copy -p"; paste="wl-paste -p"; backend=Wayland
else
copy="xclip -i"; paste="xclip -o"; backend=X11
fi
;;
Darwin) copy="pbcopy"; paste="pbpaste"; backend=OSX ;;
esac
fi
printf "map global user -docstring 'paste (after) from clipboard' p '<a-!>%s<ret>'\n" "$paste"
printf "map global user -docstring 'paste (before) from clipboard' P '!%s<ret>'\n" "$paste"
printf "map global user -docstring 'yank to primary' y '<a-|>%s<ret>:echo -markup %%{{Information}copied selection to %s primary}<ret>'\n" "$copy" "$backend"
printf "map global user -docstring 'yank to clipboard' Y '<a-|>%s<ret>:echo -markup %%{{Information}copied selection to %s clipboard}<ret>'\n" "$copy -selection clipboard" "$backend"
printf "map global user -docstring 'replace from clipboard' R '|%s<ret>'\n" "$paste"
}