Use kak as a man page viewer (I am using fish shell):
set -gx MANPAGER 'col -b -x | kak -e "map global normal q :quit<ret>; set buffer filetype man; $@"'
Then type man sed:
$ man sed
That leads to the following error message printed in the **debug** buffer:

Viewing the *debug* buffer gives the following outcome:
*** This is the debug buffer, where debug info will be written ***
error running hook WinResize(65.155)/man-hooks: 1:2: 'man-impl' wrong argument count
Looking at man.kak the following is the case (NOTE how WinResize calls man-impl with one argument but man-impl wants -params 2..3:
hook global WinSetOption filetype=man %{
hook -group man-hooks window WinResize .* %{ man-impl %opt{manpage} }
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window man-hooks }
}
define-command -hidden -params 2..3 man-impl %{ evaluate-commands %sh{
buffer_name="$1"
shift
manout=$(mktemp "${TMPDIR:-/tmp}"/kak-man-XXXXXX)
manerr=$(mktemp "${TMPDIR:-/tmp}"/kak-man-XXXXXX)
colout=$(mktemp "${TMPDIR:-/tmp}"/kak-man-XXXXXX)
env MANWIDTH=${kak_window_range##* } man "$@" > "$manout" 2> "$manerr"
retval=$?
col -b -x > ${colout} < ${manout}
rm ${manout}
if [ "${retval}" -eq 0 ]; then
printf %s\\n "
edit -scratch %{*$buffer_name ${*}*}
execute-keys '%|cat<space>${colout}<ret>gk'
nop %sh{ rm ${colout}; rm ${manerr} }
set-option buffer filetype man
set-option window manpage $buffer_name $*
"
else
printf '
fail %%{%s}
nop %%sh{ rm "%s"; rm "%s" }
' "$(cat "$manerr")" "${colout}" "${manerr}"
fi
} }
No error should be printed in the *debug* buffer when using kak as a man pager.
It looks like the man filetype is intended to call man internally, as opposed to just formatting the output of man, which does let it do things like properly render the text when the window is resized (which is what you are running up against). Maybe there should be a "plain" man filetype?
For a workaround, using a function instead of modifying the MANPAGER environment variable works:
function man
kak -e "map global normal q :quit<ret>; man $argv"
end
This does have the downside of not handling the man <section> <topic> (e.g. man 1 echo) case at all, however man <topic>.<section> (man echo.1) works fine.
#!/bin/sh
col -b -x | kak -e 'set buffer filetype man; remove-hooks window man-hooks; map buffer normal q :q<ret>'
this one works
@losnappas: Thanks. I can confirm this resolves the issue.
I will leave the BUG opened as I am not sure how the developers would categorize this (i.e. bug with workaround or improper use in the first place).
Most helpful comment
this one works