Fix #1608 - Treat .h as C++ files for C++ clang-tidy

This commit is contained in:
w0rp 2020-08-10 02:33:50 +01:00
parent 2237f9b462
commit d3f410b6f7
No known key found for this signature in database
GPG Key ID: 0FC1ECAA8C81CD83
2 changed files with 6 additions and 0 deletions

View File

@ -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')

View File

@ -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')