From d3f410b6f723603bb3bcd121758868deae37ba94 Mon Sep 17 00:00:00 2001 From: w0rp Date: Mon, 10 Aug 2020 02:33:50 +0100 Subject: Fix #1608 - Treat .h as C++ files for C++ clang-tidy --- ale_linters/cpp/clangtidy.vim | 5 +++++ test/command_callback/test_clang_tidy_command_callback.vader | 1 + 2 files changed, 6 insertions(+) diff --git a/ale_linters/cpp/clangtidy.vim b/ale_linters/cpp/clangtidy.vim index 191b7b07..5e062d86 100644 --- a/ale_linters/cpp/clangtidy.vim +++ b/ale_linters/cpp/clangtidy.vim @@ -25,6 +25,11 @@ function! ale_linters#cpp#clangtidy#GetCommand(buffer, output) abort let l:options .= !empty(l:options) ? ale#Pad(l:cflags) : l:cflags endif + " Tell clang-tidy a .h header with a C++ filetype in Vim is a C++ file. + if expand('#' . a:buffer) =~# '\.h$' + let l:options .= !empty(l:options) ? ' -x c++' : '-x c++' + endif + " Get the options to pass directly to clang-tidy let l:extra_options = ale#Var(a:buffer, 'cpp_clangtidy_extra_options') diff --git a/test/command_callback/test_clang_tidy_command_callback.vader b/test/command_callback/test_clang_tidy_command_callback.vader index eb1220be..f0a07e8c 100644 --- a/test/command_callback/test_clang_tidy_command_callback.vader +++ b/test/command_callback/test_clang_tidy_command_callback.vader @@ -68,6 +68,7 @@ Execute(The build directory should be used for header files): \ ale#Escape('clang-tidy') \ . ' -checks=' . ale#Escape('*') . ' %s' \ . ' -p ' . ale#Escape('/foo/bar') + \ . ' -- -x c++' call ale#test#SetFilename('test.hpp') -- cgit v1.2.3