我可以使用源文件clang-tidy -p build/compile_commands.json filename.h
运行clang-tidy,它可以按预期工作。当我通过vim打开文件时,我遇到了第一个#includes的错误,如果我不调用-p
选项,就会发生这种情况。
[在我的vimrc中,我尝试将g:ale_c_build_dir
设置为build
,但这没有用,所以我尝试使用上面的g:ale_cpp_clangtidy_extra_options
参数设置-p
,但没有用。我可以确认是否已使用ALEInfo
正确设置了这些值,显然它们并未在clang-tidy调用中使用。
我目前正在尝试使用clang-tidy自己设置ALE,并最终使其与以下配置一起使用:
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
如您所见,由于您的g:ale_c_build_dir_names
位于g:ale_c_build_dir
或[C0中,因此默认设置可以很好地完成工作(请参见以下文档的摘录),因为我跳过了compile_commands.json
或build
的设置项目根目录的]目录。我注意到的一件事是,当用作ALE的棉短绒时,用c整齐的棉绒非常缓慢。
bin
和:
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)