1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-01 16:32:54 +03:00
kakoune/rc/base/file.kak

18 lines
673 B
Plaintext
Raw Normal View History

hook global BufOpenFile .* %{ evaluate-commands %sh{
if [ -z "${kak_opt_filetype}" ]; then
mime=$(file -b --mime-type "${kak_buffile}")
2016-12-07 16:00:06 +03:00
case "${mime}" in
application/*+xml) filetype="xml" ;;
2017-06-02 16:43:51 +03:00
image/*+xml) filetype="xml" ;; #SVG
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/}" ;;
application/*) filetype="${mime#application/}" ;;
2016-12-07 16:00:06 +03:00
esac
if [ -n "${filetype}" ]; then
printf "set-option buffer filetype '%s'\n" "${filetype}"
fi
fi
} }