当前位置:网站首页>Configure clangd for vscode
Configure clangd for vscode
2022-08-02 15:26:00 【Hongyao】
目录
clangdCan provide better completions and hints,Bring your own checkswarning的问题,It can reduce everyone's future looking for existencewarning的时间.After configuration can be inunittest和timetestAutocompletion is also implemented in ,平均速度比vscode c/c++Plugins are faster.
安装clangd 后端
sudo apt-get install clangd
安装clangd 前端
在插件市场搜索clangd.安装即可.注意c/c++可以不用卸载,Otherwise debugging might be a bit problematic.
修改基础配置
在project folder下建立.vscode文件夹,创建settings.json文件.如下图
settings.json内容如下(Note that local configuration may also be requiredclangd.arguments否则可能会有问题,Chen Tianhao has this problem)
{
"files.associations": {
"iostream": "cpp",
"intrinsics.h": "c",
"ostream": "cpp",
"vector": "cpp"
},
// Turn on paste save auto format
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"C_Cpp.errorSquiggles": "Disabled",
"C_Cpp.intelliSenseEngineFallback": "Disabled",
"C_Cpp.intelliSenseEngine": "Disabled",
"C_Cpp.autocomplete": "Disabled", // So you don't get autocomplete from both extensions.
"clangd.path": "/usr/bin/clangd",
// Clangd 运行参数(在终端/命令行输入 clangd --help-list-hidden 可查看更多)
"clangd.arguments": [
// 让 Clangd Generate more detailed logs
"--log=verbose",
// 输出的 JSON The files are more beautiful
"--pretty",
// 全局补全(Suggestions that pop up as you type will be provided CMakeLists.txt possible symbols in all files configured in ,会自动补充头文件)
"--all-scopes-completion",
// Suggested style:打包(Overloaded functions will only give a suggestion)
// Instead it can be set to detailed
"--completion-style=bundled",
// Rename variables across files
"--cross-file-rename",
// Supplemental header files are allowed
"--header-insertion=iwyu",
// Enter suggestions,Items that already contain a header file are distinguished from items that do not yet contain a header file by a dot
"--header-insertion-decorators",
// 在后台自动分析文件(基于 complie_commands,我们用CMake生成)
"--background-index",
// 启用 Clang-Tidy 以提供「静态检查」
"--clang-tidy",
// Clang-Tidy Statically checked parameters,Indicates which rules are used for static checking,详情见「and configured according to the official documentation VSCode advantage over having」
// the part after the parameter*表示通配符
// added before the parameter-,如-modernize-use-trailing-return-type,A rule will be disabled
"--clang-tidy-checks=cppcoreguidelines-*,performance-*,bugprone-*,portability-*,modernize-*,google-*",
// Default formatting style: Google Open Source Project Code Guidelines
// "--fallback-style=file",
// 同时开启的任务数量
"-j=2",
// pch优化的位置(memory 或 disk,选择memory会增加内存开销,But it will improve performance) Recommended for use on boardsdisk
"--pch-storage=disk",
// When this is enabled,When completing a function,Placeholders will be provided for parameters,press after typing Tab You can switch to the next placeholder,to the end of the function
// I choose to disable
"--function-arg-placeholders=false",
// compelie_commands.json 文件的目录位置(relative to the workspace,由于 CMake This file is generated by default build 文件夹中,故设置为 build)
"--compile-commands-dir=build"
],
}
生成compile_commands.json文件
Make sure that the project can be compiled normally
cd build
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 .. -G 'Unix Makefiles'
之后在build目录下就会生成对应的compile_commands.json,格式如下.Just make sure it's therecompile_commands.json文件,这是clangd补全依赖文件,否则会失效.
[
{
"directory": "",
"command": "",
"file": "",
},
]
It may need to be started manually after the build is completereload window或者使用manually activate extension.之后每次打开projectUsually it starts automatically.
可以通过ps -ef | grep clang
查看是否存在进程
基本效果
补全
warning提醒
There is a problem with automatic modification
注意事项
- It is best to use the image below after useclose remote关闭,Otherwise, there may be processes in the background that are not closed
- when the process is compiled,clangdThe cache is automatically regenerated,It will take up a lot of hard disk space and may need to be cleaned regularly
边栏推荐
- Binder机制(下篇)
- Tensorflow常用函数
- 实战美团Nuxt +Vue全家桶,服务端渲染,邮箱验证,passport鉴权服务,地图API引用,mongodb,redis等技术点
- PyTorch(12)---损失函数和反向传播
- 将SSE指令转换为ARM NEON指令
- Mysql connection error solution
- Win10 can't start WampServer icon is orange solution
- FP7195转模拟恒流调光芯片在机器视觉光源的应用优势
- How to update Win11 sound card driver?Win11 sound card driver update method
- Win7怎么干净启动?如何只加载基本服务启动Win7系统
猜你喜欢
Use tencent cloud builds a personal blog
使用 腾讯云搭建一个个人博客
PyTorch④---DataLoader的使用
FP6296锂电池升压 5V9V12V内置 MOS 大功率方案原理图
win10无法直接用照片查看器打开图片怎么办
Binder ServiceManager解析
How to reinstall Win7 system with U disk?How to reinstall win7 using u disk?
Win11怎么在右键菜单添加一键关机选项
Win7 encounters an error and cannot boot into the desktop normally, how to solve it?
13.56MHZ刷卡芯片CI521兼容cv520/ci520支持A卡B卡MIFARE协议
随机推荐
Win10上帝模式干嘛的?Win10怎么开启上帝模式?
DP1101兼容CC1101是SUB1GHz无线收发芯片应用于智能家居
Actual combat Meituan Nuxt +Vue family bucket, server-side rendering, mailbox verification, passport authentication service, map API reference, mongodb, redis and other technical points
蓝牙温度检测系统(基于BT08-B蓝牙模块)
5. Use RecyclerView to elegantly achieve waterfall effect
win10系统更新错误代码0x80244022怎么办
用U盘怎么重装Win7系统?如何使用u盘重装系统win7?
实战美团Nuxt +Vue全家桶,服务端渲染,邮箱验证,passport鉴权服务,地图API引用,mongodb,redis等技术点
Spark及相关生态组件安装配置——快速回忆
Win11声卡驱动如何更新?Win11声卡驱动更新方法
STM32LL库使用——SPI通信
FP7195转模拟恒流调光芯片在机器视觉光源的应用优势
Win7 encounters an error and cannot boot into the desktop normally, how to solve it?
PyTorch(13)---优化器_随机梯度下降法
TypeScript 快速进阶
发布模块到npm应该怎么操作?及错误问题解决方案
FP7195降压恒流PWM转模拟调光零压差大功率驱动方案原理图
FP7195转模拟调光技术解决智能家居调光频闪和电感噪音的原理
【使用Pytorch实现ResNet网络模型:ResNet50、ResNet101和ResNet152】
LORA芯片ASR6601支持M4内核的远距离传输芯片