From 42963051710cb8230256d8ca46b84295a93dd6c0 Mon Sep 17 00:00:00 2001 From: Tim Allen Date: Thu, 3 Sep 2020 01:19:20 +1000 Subject: [PATCH] doc.kak: Also search through plugins (stdlib and per-user) for docs. This makes the somewhat-dubious assumption that every plugin will have uniquely- named documentation files, instead of automatically putting every plugin's docs into a namespace. However, plugins already have to deal with flat namespaces for commands, options, filetypes, etc. so one more shouldn't hurt. Fixes #2466. --- rc/tools/doc.kak | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/rc/tools/doc.kak b/rc/tools/doc.kak index 6e0cf74e..b68f9363 100644 --- a/rc/tools/doc.kak +++ b/rc/tools/doc.kak @@ -137,9 +137,19 @@ define-command -params 1 -hidden doc-render %{ define-command -params 1..2 \ -shell-script-candidates %{ if [ "$kak_token_to_complete" -eq 0 ]; then - find "${kak_runtime}/doc/" -type f -name "*.asciidoc" | sed 's,.*/,,; s/\.[^/]*$//' + ( + find "${kak_runtime}/doc/" -type f -name "*.asciidoc" + find "${kak_runtime}/rc/" -type f -name "*.asciidoc" + find "${kak_config}/autoload/" -type f -name "*.asciidoc" + ) | sed 's,.*/,,; s/\.[^/]*$//' elif [ "$kak_token_to_complete" -eq 1 ]; then - readonly page="${kak_runtime}/doc/${1}.asciidoc" + page=$( + ( + find "${kak_runtime}/doc/" -type f -name "$1.asciidoc" + find "${kak_runtime}/rc/" -type f -name "$1.asciidoc" + find "${kak_config}/autoload/" -type f -name "$1.asciidoc" + ) | head -1 + ) if [ -f "${page}" ]; then awk ' /^==+ +/ { sub(/^==+ +/, ""); print } @@ -153,7 +163,13 @@ define-command -params 1..2 \ An optional keyword argument can be passed to the function, which will be automatically selected in the documentation } %{ evaluate-commands %sh{ - readonly page="${kak_runtime}/doc/${1}.asciidoc" + page=$( + ( + find "${kak_runtime}/doc/" -type f -name "$1.asciidoc" + find "${kak_runtime}/rc/" -type f -name "$1.asciidoc" + find "${kak_config}/autoload/" -type f -name "$1.asciidoc" + ) | head -1 + ) if [ -f "${page}" ]; then jump_cmd="" if [ $# -eq 2 ]; then