2013-04-18 19:07:31 +02:00
|
|
|
decl str docsclient
|
|
|
|
|
|
|
|
hook global WinSetOption filetype=man %{
|
|
|
|
addhl group man-highlight
|
|
|
|
addhl -group man-highlight regex ^\S.*?$ 0:blue
|
|
|
|
addhl -group man-highlight regex ^\h+-+[-a-zA-Z_]+ 0:yellow
|
|
|
|
addhl -group man-highlight regex [-a-zA-Z_.]+\(\d\) 0:green
|
2014-06-16 21:42:12 +02:00
|
|
|
hook window -group man-hooks NormalKey <c-m> man
|
2013-10-30 10:38:40 +01:00
|
|
|
set buffer tabstop 8
|
2013-04-18 19:07:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
hook global WinSetOption filetype=(?!man).* %{
|
|
|
|
rmhl man-higlight
|
|
|
|
rmhooks window man-hooks
|
|
|
|
}
|
|
|
|
|
2015-12-01 15:00:55 +01:00
|
|
|
def -hidden -params .. _man %{ %sh{
|
2014-03-06 22:33:01 +01:00
|
|
|
manout=$(mktemp /tmp/kak-man-XXXXXX)
|
|
|
|
colout=$(mktemp /tmp/kak-man-XXXXXX)
|
|
|
|
MANWIDTH=${kak_window_width} man "$@" > $manout
|
|
|
|
retval=$?
|
|
|
|
col -b > ${colout} < ${manout}
|
|
|
|
rm ${manout}
|
|
|
|
if [ "${retval}" -eq 0 ]; then
|
|
|
|
echo "${output}" |
|
2013-04-18 19:07:31 +02:00
|
|
|
echo "edit! -scratch '*man*'
|
2014-03-06 22:33:01 +01:00
|
|
|
exec |cat<space>${colout}<ret>gk
|
|
|
|
nop %sh{rm ${colout}}
|
2013-10-30 10:38:40 +01:00
|
|
|
set buffer filetype man"
|
2013-04-18 19:07:31 +02:00
|
|
|
else
|
2014-01-08 20:18:51 +01:00
|
|
|
echo "echo -color Error %{man '$@' failed: see *debug* buffer for details }"
|
2014-03-06 22:33:01 +01:00
|
|
|
rm ${colout}
|
2013-04-18 19:07:31 +02:00
|
|
|
fi
|
2013-12-07 14:56:56 +01:00
|
|
|
} }
|
|
|
|
|
2015-12-01 15:00:55 +01:00
|
|
|
def -params .. \
|
2015-07-03 22:00:10 +02:00
|
|
|
-shell-completion %{
|
|
|
|
prefix=${1:0:${kak_pos_in_token}}
|
2015-09-11 13:55:55 +02:00
|
|
|
for page in /usr/share/man/*/${prefix}*.[1-8]*; do
|
|
|
|
candidate=$(basename ${page%%.[1-8]*})
|
2015-12-16 15:48:33 +01:00
|
|
|
pagenum=$(echo $page | sed -r 's,^.+/.+\.([1-8][^.]*)\..+$,\1,')
|
2015-07-20 14:16:05 +02:00
|
|
|
case $candidate in
|
|
|
|
*\*) ;;
|
2015-12-01 10:09:26 +01:00
|
|
|
*) echo $candidate\($pagenum\);;
|
2015-07-20 14:16:05 +02:00
|
|
|
esac
|
2015-07-03 22:00:10 +02:00
|
|
|
done
|
|
|
|
} \
|
2015-08-03 20:44:27 +02:00
|
|
|
man -docstring "Manpages viewer wrapper" %{ %sh{
|
2015-12-01 10:09:26 +01:00
|
|
|
subject=${@-$kak_selection}
|
|
|
|
pagenum=""
|
|
|
|
|
|
|
|
## The completion suggestions display the page number, strip them if present
|
|
|
|
if [[ $subject =~ [a-zA-Z_-]+\([^\)]+\) ]]; then
|
|
|
|
pagenum=${subject##*\(}
|
|
|
|
pagenum=${pagenum:0:$((${#pagenum} - 1))}
|
|
|
|
subject=${subject%%\(*}
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "eval -try-client %opt{docsclient} _man $pagenum $subject"
|
2013-12-07 14:56:56 +01:00
|
|
|
} }
|