doc.kak: anchor/section completion support

This commit is contained in:
Maxime Coste 2017-11-08 17:20:37 +08:00
parent b63f16e7a2
commit b8fdcff7b0

View File

@ -122,7 +122,17 @@ define-command -params 1 -hidden doc-render %{
define-command -params 1..2 \
-shell-candidates %{
if [ "$kak_token_to_complete" -eq 0 ]; then
find "${kak_runtime}/doc/" -type f -name "*.asciidoc" | sed 's,.*/,,; s/\.[^/]*$//'
elif [ "$kak_token_to_complete" -eq 1 ]; then
readonly page="${kak_runtime}/doc/${1}.asciidoc"
if [ -f "${page}" ]; then
awk '
/^==+ +/ { sub(/^==+ +/, ""); print }
/^\[\[[^\]]+\]\]/ { sub(/^\[\[/, ""); sub(/\]\].*/, ""); print }
' < $page
fi
fi
} \
doc -docstring %{doc <topic> [<keyword>]: open a buffer containing documentation about a given topic
An optional keyword argument can be passed to the function, which will be automatically selected in the documentation} %{