From b3c293a9da23286694f4cd7fac060b1b011e3d4b Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 7 Aug 2012 13:51:51 +0200 Subject: [PATCH] cpp.kak: also try to detect cpp files using the file tool --- src/rc/cpp.kak | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/rc/cpp.kak b/src/rc/cpp.kak index 15992ce5..766a7a60 100644 --- a/src/rc/cpp.kak +++ b/src/rc/cpp.kak @@ -2,6 +2,13 @@ hook global BufCreate .*\.(c|cc|cpp|cxx|C|h|hh|hpp|hxx|H) %{ setb filetype cpp } +hook global BufOpen .* %{ %sh{ + mimetype="$(file -b --mime-type ${kak_bufname})" + if [[ "${mimetype}" == "text/x-c++" || "${mimetype}" == "text/x-c" ]]; then + echo setb filetype cpp; + fi +} } + hook global WinSetOption filetype=cpp %{ addhl group cpp-highlight; addhl -group cpp-highlight regex "\<(this|true|false|NULL|nullptr|)\>|\<-?\d+[fdiu]?|'((\\.)?|[^'\\])'" 0:red