diff --git a/rc/detection/file.kak b/rc/detection/file.kak index faf93e6b..99e0b05b 100644 --- a/rc/detection/file.kak +++ b/rc/detection/file.kak @@ -1,4 +1,4 @@ -hook global BufOpenFile .* %{ evaluate-commands %sh{ +define-command -hidden file-detection %{ evaluate-commands %sh{ if [ -z "${kak_opt_filetype}" ]; then mime=$(file -b --mime-type -L "${kak_buffile}") mime=${mime%;*} @@ -9,6 +9,7 @@ hook global BufOpenFile .* %{ evaluate-commands %sh{ text/x-shellscript) filetype="sh" ;; text/x-script.*) filetype="${mime#text/x-script.}" ;; text/x-*) filetype="${mime#text/x-}" ;; + text/plain) exit ;; text/*) filetype="${mime#text/}" ;; application/x-shellscript) filetype="sh" ;; application/x-*) filetype="${mime#application/x-}" ;; @@ -20,3 +21,6 @@ hook global BufOpenFile .* %{ evaluate-commands %sh{ fi fi } } + +hook global BufOpenFile .* file-detection +hook global BufWritePost .* file-detection