我能够使用我的源文件clang-tidy -p build/compile_commands.json filename.h
运行clang,并且它可以像预期的那样工作。当我通过vim打开文件时,我会得到第一个#include的错误,如果不调用-p
选项,就会发生这种情况。
在我的vimrc中,我尝试将g:ale_c_build_dir
设置为build
,但这不起作用,所以我尝试使用上面的-p
参数设置g:ale_cpp_clangtidy_extra_options
,但这不起作用。我能够确认这些值是用ALEInfo
正确设置的,它们显然没有被用于clang调用。
发布于 2020-05-24 08:24:32
我目前正在尝试用clang自己来设置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
,因为默认设置应该做得很好(请参阅下面文档中的摘录),因为您的compile_commands.json
驻留在项目根目录的build
或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)
和:
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.
https://stackoverflow.com/questions/61493971
复制相似问题