z_mirror/dotfiles

git clone https://git.raiguard.me/z_mirror/dotfiles

Caleb HeuerMiscddae1e8

uraya-alpine
2.0 KiB56 linesraw
1declare-option str my_jump_buffers \*(grep|find|callers|callees|goto|symbols|diagnostics|frun)\b.*\*
2declare-option str my_make_buffers \*(cargo|make)\*
3
4map global normal <c-a-n> %{:jump-next -matching %opt{my_jump_buffers}<ret>} -docstring 'next location'
5map global normal <c-a-p> %{:jump-previous -matching %opt{my_jump_buffers}<ret>} -docstring 'previous location'
6map global normal <c-a-e> %{:my-push-buffer<ret>} -docstring 'push buffer'
7map global normal <c-a-r> %{:my-jump-buffer-pop %opt{my_jump_buffers}<ret>} -docstring 'pop jump buffer'
8map global user j %{:buffer -matching %opt{my_jump_buffers}<ret>} -docstring "latest jump buffer"
9
10define-command -override my-push-buffer %{
11	declare-option str my_push_buffer_safeguard nop
12	evaluate-commands %sh{
13		if printf %s "${kak_bufname}" | grep -q '^\*'; then {
14			basename=$(printf %s "${kak_bufname}" | sed 's,\(-[0-9]*\)\?\*$,,')
15			echo "rename-buffer -unique $basename-|*"
16		} else {
17			echo  "
18			%opt{my_push_buffer_safeguard}
19			set-option local my_push_buffer_safeguard %{fail recursion}
20			evaluate-commands -draft %{
21				buffer -matching %opt{my_jump_buffers}
22				my-push-buffer
23			}
24			"
25		} fi
26	}
27}
28define-command my-jump-buffer-pop -params 1 -docstring %{
29	delete the given buffer.
30	Activate the new last buffer in the client specified in the 'toolsclient'
31	option. If the active client is different from 'toolsclient', jump to
32	the current location.
33} %{
34	buffer -matching %arg{1}
35	delete-buffer
36	try %{
37		evaluate-commands -save-regs b %{
38			evaluate-commands -try-client %opt{toolsclient} %{
39				buffer -matching %arg{1}
40				set-register b %val{bufname}
41			}
42			evaluate-commands -try-client %opt{jumpclient} %{
43				evaluate-commands %sh{
44					if [ -n "${kak_opt_toolsclient}" ] &&
45					[ "${kak_client}" != "${kak_opt_toolsclient}" ]; then
46					echo buffer %reg{b}
47					echo jump
48					fi
49				}
50			}
51			echo -markup {Information}{\}returned to buffer %reg{b}
52		}
53	} catch %{
54		echo -markup {Information}no jump buffer remaining
55	}
56}