Created
April 11, 2021 11:27
-
-
Save Screwtapello/5ff1be32fccf62acd1830aeaf8d7b69d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare-option -hidden range-specs fold_regions 0 | |
add-highlighter global/fold-regions replace-ranges fold_regions | |
# range-specs option format: | |
# | |
# - a timestamp (like %val{timestamp}) | |
# - zero or more "a.b,c.d|string", where: | |
# - a is the start line | |
# - b is the start byte in the start line | |
# - c is the end line | |
# - d is the end byte in the end line | |
# - string is a markup string of replacement text | |
# mark register format: | |
# | |
# - <buffer name>@<timestamp>@<main sel index> | |
# - zero or more "a.b,c.d" | |
hook global RegisterModified \^ %{ | |
eval %sh{ | |
eval set -- "$kak_quoted_reg_caret" | |
name_and_timestamp=${1%@*} | |
name=${name_and_timestamp%@*} | |
timestamp=${name_and_timestamp##*@} | |
shift | |
echo "echo -debug running in file $kak_buffile" | |
if [ x"$kak_buffile" != x"$name" ]; then | |
# The register value doesn't apply to this file, | |
# ignore the update. | |
exit | |
fi | |
echo "set-option buffer fold_regions $timestamp" | |
for span; do | |
echo "set-option -add buffer fold_regions '$span|----'" | |
done | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment