blob: 7c4bb5abdcfdbc4ad10b1494abe961dd57241177 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
map global normal <c-p> ': snippets-insert<ret>'
declare-option str snippets_dir "%val{config}/snippets"
define-command snippets-insert -docstring 'Snippets' %{
prompt -menu "Snippets: " -init "%opt{filetype}/" \
-shell-script-candidates %{ fd --type file --base-directory "$kak_opt_snippets_dir" } \
%{
evaluate-commands %sh{
case "$kak_text" in
*.snip.kak) cat "$kak_opt_snippets_dir/$kak_text" ;;
*) echo "insert-text-snippet %{$kak_text}" ;;
esac
}
}
}
define-command -hidden insert-text-snippet -params 1 %{
execute-keys ",|cat ""%opt{snippets_dir}/%arg{1}""<ret>"
execute-keys -save-regs '' "s[$]\d+<ret>"
execute-keys "%sh{echo $((kak_selection_count + 1))}n"
}
|