From 7750df787a11606730e847667c0ebaf35e888400 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 22 Sep 2015 18:50:05 +0100 Subject: [PATCH] Try to manually detect if .h files are c or cpp --- rc/c-family.kak | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/rc/c-family.kak b/rc/c-family.kak index b932dfb2..f09a5b49 100644 --- a/rc/c-family.kak +++ b/rc/c-family.kak @@ -3,11 +3,21 @@ hook global BufCreate .*\.(cc|cpp|cxx|C|hh|hpp|hxx|H)$ %{ set buffer mimetype '' } -hook global BufCreate .*\.(c|h)$ %{ +hook global BufCreate .*\.c$ %{ set buffer filetype c set buffer mimetype '' } +hook global BufCreate .*\.h$ %{ + try %{ + exec %{%s\b::\b|\btemplate\h*|\bclass\h+\w+|\b(typename|namespace)\b|\b(public|private|protected)\h*:} + set buffer filetype cpp + } catch %{ + set buffer filetype c + } + set buffer mimetype '' +} + hook global BufSetOption mimetype=text/x-c %{ set buffer filetype c }