diff --git a/rc/core/doc.kak b/rc/core/doc.kak index e91cc60d..847e93bd 100644 --- a/rc/core/doc.kak +++ b/rc/core/doc.kak @@ -122,7 +122,17 @@ define-command -params 1 -hidden doc-render %{ define-command -params 1..2 \ -shell-candidates %{ - find "${kak_runtime}/doc/" -type f -name "*.asciidoc" | sed 's,.*/,,; s/\.[^/]*$//' + 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 []: 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} %{