diff --git a/rc/base/clojure.kak b/rc/base/clojure.kak index 1336bd41..194a2815 100644 --- a/rc/base/clojure.kak +++ b/rc/base/clojure.kak @@ -6,10 +6,6 @@ # Detection # ‾‾‾‾‾‾‾‾‾ -hook global BufSetOption mimetype=text/x-clojure %{ - set buffer filetype clojure -} - hook global BufCreate .*[.](cljs?) %{ set buffer filetype clojure } diff --git a/rc/base/css.kak b/rc/base/css.kak index 06c483aa..27a58712 100644 --- a/rc/base/css.kak +++ b/rc/base/css.kak @@ -4,10 +4,6 @@ # Detection # ‾‾‾‾‾‾‾‾‾ -hook global BufSetOption mimetype=text/x-css %{ - set buffer filetype css -} - hook global BufCreate .*[.](css) %{ set buffer filetype css } diff --git a/rc/base/d.kak b/rc/base/d.kak index d5ab7df9..3344572b 100644 --- a/rc/base/d.kak +++ b/rc/base/d.kak @@ -5,7 +5,6 @@ # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*\.di? %{ - set buffer mimetype "" set buffer filetype d } diff --git a/rc/base/file.kak b/rc/base/file.kak new file mode 100644 index 00000000..0aef21ec --- /dev/null +++ b/rc/base/file.kak @@ -0,0 +1,13 @@ +decl str mimetype + +hook global BufOpen .* %{ %sh{ + if [ -z "${kak_opt_filetype}" ]; then + mime=$(file -b --mime-type "${kak_buffile}") + printf %s\\n "${mime}" | grep -q '^text/x-' + if [ $? -eq 0 ]; then + printf "set buffer filetype '%s'\n" "${mime:7}" + else + printf "set buffer mimetype '%s'\n" "${mime}" + fi + fi +} } diff --git a/rc/base/fish.kak b/rc/base/fish.kak index 81c1dabc..6bb4a5f5 100644 --- a/rc/base/fish.kak +++ b/rc/base/fish.kak @@ -4,10 +4,6 @@ # Detection # ‾‾‾‾‾‾‾‾‾ -hook global BufSetOption mimetype=text/x-fish %{ - set buffer filetype fish -} - hook global BufCreate .*[.](fish) %{ set buffer filetype fish } diff --git a/rc/base/go.kak b/rc/base/go.kak index b925576a..0b0be61b 100644 --- a/rc/base/go.kak +++ b/rc/base/go.kak @@ -5,7 +5,6 @@ # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*\.go %{ - set buffer mimetype "" set buffer filetype go } diff --git a/rc/base/haskell.kak b/rc/base/haskell.kak index 823c4be0..bb5fb5c1 100644 --- a/rc/base/haskell.kak +++ b/rc/base/haskell.kak @@ -4,10 +4,6 @@ # Detection # ‾‾‾‾‾‾‾‾‾ -hook global BufSetOption mimetype=text/x-haskell %{ - set buffer filetype haskell -} - hook global BufCreate .*[.](hs) %{ set buffer filetype haskell } diff --git a/rc/base/java.kak b/rc/base/java.kak index 606f0318..1ccc82fc 100644 --- a/rc/base/java.kak +++ b/rc/base/java.kak @@ -2,10 +2,6 @@ hook global BufCreate .*\.java %{ set buffer filetype java } -hook global BufSetOption mimetype=text/java %{ - set buffer filetype java -} - addhl -group / regions -default code java \ string %{(?