Detect filetype on buffer save too
This allow kaking a new file, add a shebang in the first line, and get the right filetype detected automatically on save.
This commit is contained in:
parent
cdcf4b0c7d
commit
36631fc473
|
@ -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-*) filetype="${mime#application/x-}" ;;
|
||||
application/*) filetype="${mime#application/}" ;;
|
||||
|
@ -19,3 +20,6 @@ hook global BufOpenFile .* %{ evaluate-commands %sh{
|
|||
fi
|
||||
fi
|
||||
} }
|
||||
|
||||
hook global BufOpenFile .* file-detection
|
||||
hook global BufWritePost .* file-detection
|
||||
|
|
Loading…
Reference in New Issue
Block a user