当前位置:网站首页>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
边栏推荐
- 将SSE指令转换为ARM NEON指令
- LeetCode2 电话号码的字母组合
- 【我的电赛日记(一)】HMI USART串口屏
- How to set the win10 taskbar does not merge icons
- 5. Use RecyclerView to elegantly achieve waterfall effect
- 【我的电赛日记(二)】ADF4351锁相环模块
- 使用npx -p @storybook/cli sb init安装失败,手把手搭建专属的storybook
- Win10上帝模式干嘛的?Win10怎么开启上帝模式?
- Binder机制(中篇)
- Win7 encounters an error and cannot boot into the desktop normally, how to solve it?
猜你喜欢
小T成长记-网络篇-1-什么是网络?
How to solve Win11 without local users and groups
How to update Win11 sound card driver?Win11 sound card driver update method
flink+sklearn——使用jpmml实现flink上的机器学习模型部署
A clean start Windows 7?How to load only the basic service start Windows 7 system
Makefile容易犯错的语法
蓝牙温度检测系统(基于BT08-B蓝牙模块)
What should I do if the Win10 system sets the application identity to automatically prompt for access denied?
Win10电脑需要安装杀毒软件吗?
win10 system update error code 0x80244022 how to do
随机推荐
DP4301无线收发SUB-1G芯片兼容CC1101智能家居
Binder ServiceManager解析
FP7195降压恒流PWM转模拟调光零压差大功率驱动方案原理图
FP5207电池升压 5V9V12V24V36V42V大功率方案
win10 system update error code 0x80244022 how to do
单端K总线收发器DP9637兼容L9637
The overlapping effect of the two surfaceviews is similar to the video and handout practice in the live effect
ARMv8虚拟化
2020-02-06-快速搭建个人博客
win10任务栏不合并图标如何设置
FP7128内置MOS降压恒流调光深度0.01%高辉共阳调光方案
用U盘怎么重装Win7系统?如何使用u盘重装系统win7?
为android系统添加产品的过程
vscode镜像
Tensorflow常用函数
FP6293电池升压5V-12V大电流2APWM模式升压方案
为vscode配置clangd
实战美团Nuxt +Vue全家桶,服务端渲染,邮箱验证,passport鉴权服务,地图API引用,mongodb,redis等技术点
DP1332E刷卡芯片支持NFC内置mcu智能楼宇/终端poss机/智能门锁
Win11系统找不到dll文件怎么修复