首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >为什么clang不让它的选择通过ALE?

为什么clang不让它的选择通过ALE?
EN

Stack Overflow用户
提问于 2020-04-29 03:56:11
回答 1查看 1.5K关注 0票数 0

我能够使用我的源文件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调用。

EN

回答 1

Stack Overflow用户

发布于 2020-05-24 08:24:32

我目前正在尝试用clang自己来设置ALE,并最终使用以下配置:

代码语言:javascript
运行
复制
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_namesg:ale_c_build_dir,因为默认设置应该做得很好(请参阅下面文档中的摘录),因为您的compile_commands.json驻留在项目根目录的buildbin目录中。有一件事我已经注意到了,当作为麦酒的林特使用时,用干净的皮棉是非常缓慢的。

代码语言:javascript
运行
复制
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)

和:

代码语言:javascript
运行
复制
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.
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61493971

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档