I am currently trying to set ALE up with clang-tidy myself, and eventually got it working with the following config:
let g:ale_linters = {
\ 'cpp': ['clangtidy'],
\ 'c': ['clangtidy'],
\}
let g:ale_fixers={
\ 'cpp': ['clang-format'],
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\}
let g:ale_cpp_clangtidy_checks = []
let g:ale_cpp_clangtidy_executable = 'clang-tidy'
let g:ale_c_parse_compile_commands=1
let g:ale_cpp_clangtidy_extra_options = ''
let g:ale_cpp_clangtidy_options = ''
let g:ale_set_balloons=1
let g:ale_linters_explicit=1
let g:airline#extensions#ale#enabled=1
As you can see, i have skipped setting g:ale_c_build_dir_names
or g:ale_c_build_dir
, since the defaults should do the job just fine (see excerpts from documentation below), given that your compile_commands.json
resides in build
or bin
directory of the root of your project. One thing i have noticed is that linting with clang-tidy when used as ALE's linter is very slow.
g:ale_c_build_dir_names
Type: List
Default: ['build', 'bin']
A list of directory names to be used when searching upwards from cpp
files to discover compilation databases with. For directory named 'foo',
ALE will search for 'foo/compile_commands.json' in all directories on and above
the directory containing the cpp file to find path to compilation database.
This feature is useful for the clang tools wrapped around LibTooling (namely
here, clang-tidy)
And:
g:ale_c_build_dir
Type: String
Default: ''
For programs that can read compile_commands.json files, this option can be
set to the directory containing the file for the project. ALE will try to
determine the location of compile_commands.json automatically, but if your
file exists in some other directory, you can set this option so ALE will
know where it is.
This directory will be searched instead of g:ale_c_build_dir_names.