add man.kak which provides a man command for displaying man pages in kakoune
This commit is contained in:
parent
03238df967
commit
7af98eae43
|
@ -34,6 +34,6 @@ XDG_CONFIG_HOME ?= $(HOME)/.config
|
||||||
|
|
||||||
userconfig:
|
userconfig:
|
||||||
mkdir -p $(XDG_CONFIG_HOME)/kak/autoload
|
mkdir -p $(XDG_CONFIG_HOME)/kak/autoload
|
||||||
ln -s $(CURDIR)/rc/{asciidoc,client,cpp,diff,git,grep,kakrc,make,sh,mail}.kak $(XDG_CONFIG_HOME)/kak/autoload/
|
ln -s $(CURDIR)/rc/{asciidoc,client,cpp,diff,git,grep,kakrc,make,sh,mail,man}.kak $(XDG_CONFIG_HOME)/kak/autoload/
|
||||||
|
|
||||||
.PHONY: tags userconfig
|
.PHONY: tags userconfig
|
||||||
|
|
36
src/rc/man.kak
Normal file
36
src/rc/man.kak
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
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 -id man-hooks NormalKey <c-m> man
|
||||||
|
setb tabstop 8
|
||||||
|
}
|
||||||
|
|
||||||
|
hook global WinSetOption filetype=(?!man).* %{
|
||||||
|
rmhl man-higlight
|
||||||
|
rmhooks window man-hooks
|
||||||
|
}
|
||||||
|
|
||||||
|
def -shell-params man %{ %sh{
|
||||||
|
[[ -z "$@" ]] && set -- "$kak_selection"
|
||||||
|
# eval in the docsclient context so that kak_window_width is the good one
|
||||||
|
if [[ -n "$kak_opt_docsclient" && "$kak_client" != "$kak_opt_docsclient" ]]; then
|
||||||
|
echo "eval -client $kak_opt_docsclient %{ man $@ }"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
tmpfile=$(mktemp /tmp/kak-man-XXXXXX)
|
||||||
|
MANWIDTH=${kak_window_width} man "$@" | col -b > ${tmpfile}
|
||||||
|
if (( ${PIPESTATUS[0]} == 0 )); then
|
||||||
|
echo "edit! -scratch '*man*'
|
||||||
|
exec |cat<space>${tmpfile}<ret>gk
|
||||||
|
nop %sh{rm ${tmpfile}}
|
||||||
|
setb filetype man"
|
||||||
|
else
|
||||||
|
echo "echo %{man '$@' failed: see *debug* buffer for details }"
|
||||||
|
rm ${tmpfile}
|
||||||
|
fi
|
||||||
|
}}
|
Loading…
Reference in New Issue
Block a user