Skip to content

Instantly share code, notes, and snippets.

@Screwtapello
Created April 11, 2021 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Screwtapello/5ff1be32fccf62acd1830aeaf8d7b69d to your computer and use it in GitHub Desktop.
Save Screwtapello/5ff1be32fccf62acd1830aeaf8d7b69d to your computer and use it in GitHub Desktop.
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