2018-05-06 23:29:52 +02:00
|
|
|
hook global BufOpenFile .* %{ evaluate-commands %sh{
|
2016-12-06 14:40:14 +01:00
|
|
|
if [ -z "${kak_opt_filetype}" ]; then
|
|
|
|
mime=$(file -b --mime-type "${kak_buffile}")
|
2016-12-07 14:00:06 +01:00
|
|
|
case "${mime}" in
|
2016-12-14 14:40:00 +01:00
|
|
|
application/*+xml) filetype="xml" ;;
|
2017-06-02 15:43:51 +02:00
|
|
|
image/*+xml) filetype="xml" ;; #SVG
|
2016-12-14 14:40:00 +01:00
|
|
|
message/rfc822) filetype="mail" ;;
|
|
|
|
text/x-shellscript) filetype="sh" ;;
|
2016-12-07 14:00:06 +01:00
|
|
|
text/x-*) filetype="${mime#text/x-}" ;;
|
|
|
|
text/*) filetype="${mime#text/}" ;;
|
2018-03-14 17:04:03 +01:00
|
|
|
application/*) filetype="${mime#application/}" ;;
|
2016-12-07 14:00:06 +01:00
|
|
|
esac
|
|
|
|
if [ -n "${filetype}" ]; then
|
2017-11-03 08:34:41 +01:00
|
|
|
printf "set-option buffer filetype '%s'\n" "${filetype}"
|
2016-12-06 14:40:14 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
} }
|