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