diff --git a/rc/tools/doc.kak b/rc/tools/doc.kak index d561dd05..b4a3b45b 100644 --- a/rc/tools/doc.kak +++ b/rc/tools/doc.kak @@ -134,34 +134,7 @@ define-command -params 1 -hidden doc-render %{ map buffer normal :doc-follow-link } -define-command -params 0..2 \ - -shell-script-candidates %{ - case "$kak_token_to_complete" in - 0) - find -L \ - "${kak_config}/autoload/" \ - "${kak_runtime}/doc/" \ - "${kak_runtime}/rc/" \ - -type f -name "*.asciidoc" 2>/dev/null | - sed 's,.*/,,; s/\.[^.]*$//';; - 1) - page=$( - find -L \ - "${kak_config}/autoload/" \ - "${kak_runtime}/doc/" \ - "${kak_runtime}/rc/" \ - -type f -name "$1.asciidoc" 2>/dev/null | - head -1 - ) - if [ -f "${page}" ]; then - awk ' - /^==+ +/ { sub(/^==+ +/, ""); print } - /^\[\[[^\]]+\]\]/ { sub(/^\[\[/, ""); sub(/\]\].*/, ""); print } - ' < $page | tr '[A-Z ]' '[a-z-]' - fi;; - esac - } -menu \ - doc -docstring %{ +define-command doc -params 0..2 -menu -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 @@ -192,4 +165,31 @@ define-command -params 0..2 \ } } +complete-command doc shell-script-candidates %{ + case "$kak_token_to_complete" in + 0) + find -L \ + "${kak_config}/autoload/" \ + "${kak_runtime}/doc/" \ + "${kak_runtime}/rc/" \ + -type f -name "*.asciidoc" 2>/dev/null | + sed 's,.*/,,; s/\.[^.]*$//';; + 1) + page=$( + find -L \ + "${kak_config}/autoload/" \ + "${kak_runtime}/doc/" \ + "${kak_runtime}/rc/" \ + -type f -name "$1.asciidoc" 2>/dev/null | + head -1 + ) + if [ -f "${page}" ]; then + awk ' + /^==+ +/ { sub(/^==+ +/, ""); print } + /^\[\[[^\]]+\]\]/ { sub(/^\[\[/, ""); sub(/\]\].*/, ""); print } + ' < $page | tr '[A-Z ]' '[a-z-]' + fi;; + esac +} + alias global help doc