1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-21 02:21:32 +03:00
kakoune/rc/man.kak

40 lines
1.1 KiB
Plaintext
Raw Normal View History

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
hook window -group man-hooks NormalKey <c-m> man
set buffer tabstop 8
}
hook global WinSetOption filetype=(?!man).* %{
rmhl man-higlight
rmhooks window man-hooks
}
def -hidden -shell-params _man %{ %sh{
2014-03-07 01:33:01 +04: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}" |
echo "edit! -scratch '*man*'
2014-03-07 01:33:01 +04:00
exec |cat<space>${colout}<ret>gk
nop %sh{rm ${colout}}
set buffer filetype man"
else
2014-01-08 23:18:51 +04:00
echo "echo -color Error %{man '$@' failed: see *debug* buffer for details }"
2014-03-07 01:33:01 +04:00
rm ${colout}
fi
} }
def -shell-params man %{ %sh{
[ -z "$@" ] && set -- "$kak_selection"
echo "eval -try-client %opt{docsclient} _man $@"
} }