diff --git a/src/Makefile b/src/Makefile index d252715e..e35dbf8e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -34,6 +34,6 @@ XDG_CONFIG_HOME ?= $(HOME)/.config userconfig: 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 diff --git a/src/rc/man.kak b/src/rc/man.kak new file mode 100644 index 00000000..6d2c27a6 --- /dev/null +++ b/src/rc/man.kak @@ -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 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${tmpfile}gk + nop %sh{rm ${tmpfile}} + setb filetype man" + else + echo "echo %{man '$@' failed: see *debug* buffer for details }" + rm ${tmpfile} + fi +}}