blob: 652111cdc269bf4f699898222cb1829ef10e4130 (
plain) (
blame)
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
|
def find -docstring "find files" -menu -params 1 \
%{ edit -existing %arg{1} } \
-shell-script-candidates %{ fd -t f --hidden --color=never -E .git }
def file-manager -params .. %{
terminal-singleton files env "DAFFM_PATH_RELATIVE_TO=%val{client_env_PWD}" daffm -c @kak %arg{@}
}
def findfzf -params .. %{
terminal-singleton fzf sh -c \
'kcr edit $(fd -t f --hidden --color=never -E .git | \
fzf --prompt='':find '' --multi --min-height=100 \
--preview=''bat --color=always {}'' \
--bind ''ctrl-o:execute(kcr edit {})'' \
$@)' findfzf-cmd %arg{@}
}
def findfzf-filtered -params 1 %{
terminal-singleton fzf sh -c \
'export pat=$1; kcr edit $(fd -t f --hidden --color=never -E .git | \
grep -E ''''$pat'''' | \
fzf --prompt='':find# '' --multi --min-height=100 \
--preview=''bat --color=always {}'' \
--info-command ''printf $pat'' \
)' findfzf-cmd %arg{1}
}
declare-user-mode file
map global user f ': enter-user-mode file<ret>' -docstring 'File mode'
map global file F ': find ' -docstring 'Find files'
map global file n ': file-manager %val{buffile}<ret>' -docstring 'File manager'
map global file f ': findfzf<ret>' -docstring 'Fzf'
map global file <c-f> ': findfzf -q %val{selection}<ret>' -docstring 'Fzf selection'
declare-user-mode buffer
map global user b ': enter-user-mode -count %val{count} buffer<ret>' -docstring 'Buffer mode'
map global buffer b ': buffer ' -docstring 'Switch buffer'
map global buffer <ret> ': buffer-jump %val{count}; buffers-show<ret>' -docstring 'Jump to buffer'
map global buffer n ': buffer-next; buffers-show<ret>' -docstring 'Next buffer'
map global buffer p ': buffer-previous; buffers-show<ret>' -docstring 'Previous buffer'
map global buffer d ': delete-buffer; buffers-show<ret>' -docstring 'Delete buffer'
map global buffer s ': write<ret>' -docstring 'Save'
def buffers-show %{
info -title 'buffers' -markup %sh{
echo "$kak_quoted_buflist" | xargs -n1 | grep -v -E '^([*]debug[*])$' | while IFS= read buf; do
if [ -z "$buf" ]; then echo "{comment}<scratch>{Normal}"
elif [ "$buf" == "$kak_bufname" ]; then echo "{keyword}$buf{Normal}"
else echo "{Default}$buf{Normal}"
fi
done | nl -w 2
}
}
def buffer-jump -params 1 %{
evaluate-commands %sh{
if ! [ "$1" == "0" ]; then
buf=$(echo "$kak_quoted_buflist" | xargs -n1 | grep -v -E '^([*]debug[*])$' | head -n "$1" | tail -n1)
[ -z "$buf" ] || printf "buffer '%s'" $(echo "$buf" | sed "s/'/''/g")
fi
}
}
|