blob: e1f7d72e9a7b9e5e28dc41df74cbd7abf28d4781 (
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
|
define-command marks-select -params 1 %{
evaluate-commands %sh{
mark=$("$kak_config/scripts/marks.fnl" get "${1:-0}")
[ -z "$mark" ] || echo "edit $mark"
}
marks-show
}
define-command marks-add -params 1..2 %{
nop %sh{ "$kak_config/scripts/marks.fnl" add "$1" "$2" }
marks-show
}
define-command marks-delete -params 1 %{
nop %sh{ "$kak_config/scripts/marks.fnl" delete "$1" }
delete-buffer %arg{1}
marks-show
}
define-command marks-clear %{
nop %sh{ "$kak_config/scripts/marks.fnl" clear }
}
define-command marks-show %{
info -title 'marks' -markup %sh{
path="$kak_opt_marks_path/$kak_opt_marks_name"
echo -n "{Default}"
marks=$("$kak_config/scripts/marks.fnl" show)
if [ -z "$marks" ]; then
echo "{comment}<empty>" && exit 0;
fi
echo "$marks" | while IFS= read file; do
short_path=$(echo "$file" | awk -F/ '{if (NF >= 2) {print $(NF-1) "/" $NF} else {print $NF}}')
hl=$([ "$file" = "$kak_buffile" ] && echo "{keyword}" || echo "{Default}")
echo "${hl}${short_path} {comment}$(realpath -s --relative-to="$PWD" "$file"){Default}"
done | nl | sed 's/^\s*//'
}
}
declare-user-mode marks
map global user a ': enter-user-mode-with-count marks<ret>' -docstring 'Marks mode'
map global user <space> ': marks-select %val{count}<ret>' -docstring 'Select marks'
map global marks a ': marks-add %val{buffile} %opt{user_mode_count}<ret>' -docstring 'Create new mark from buffer'
map global marks d ': marks-delete %val{buffile}<ret>' -docstring 'Delete mark'
map global marks C ': marks-clear<ret>' -docstring 'Clear mark'
|