VsCode+Clangd+SSH+CMake
安装
- Linux上安装Clangd,CMake
- 安装VsCode,安装VsCode插件clangd, ssh, CMake
配置
1.VsCode的Clangd插件配置Linux上的Clangd路径。
2.VsCode配置Clangd功能
cpp
{
// clangd 补全
"editor.formatOnPaste": true,
"editor.formatOnType": true,
"C_Cpp.errorSquiggles": "Disabled",
"C_Cpp.intelliSenseEngineFallback": "Disabled",
"C_Cpp.intelliSenseEngine": "Disabled",
"clangd.path": "/usr/bin/clangd",
"clangd.arguments": [
"--compile-commands-dir=${workspaceFolder}/build",
"--query-driver=/home/ljx/workspace/tools/xxx/bin/*",
"--enable-config",
"--log=verbose",
"--pretty",
"--all-scopes-completion",
"--completion-style=bundled",
"--cross-file-rename",
"--header-insertion=iwyu",
"--header-insertion-decorators",
"--background-index",
"--clang-tidy",
"-j=2",
"--pch-storage=disk",
"--function-arg-placeholders=false",
"--compile-commands-dir=build"
],
"clangd.fallbackFlags": [
"-pedantic",
"-Wall",
"-Wextra",
"-Wcast-align",
"-Wdouble-promotion",
"-Wformat=2",
"-Wimplicit-fallthrough",
"-Wmisleading-indentation",
"-Wnon-virtual-dtor",
"-Wnull-dereference",
"-Wold-style-cast",
"-Woverloaded-virtual",
"-Wpedantic",
"-Wshadow",
"-Wunused",
"-pthread",
"-fuse-ld=lld",
"-fsanitize=address",
"-fsanitize=undefined",
"-stdlib=libc++",
"-std=c++17"
],
}
3.Linux上 ~/config/clangd/config.yaml配置忽略语法
bash
CompileFlags:
Add: -Wno-unknown-warning-option
Remove: [-march=*, -mabi=*, -f*, -V*, ]
Diagnostics:
Suppress: ['drv_unknown_argument', 'unused-includes', 'pp_file_not_found', 'drv_unsupported_opt', ]
4.CMake添加生成COMPILE_COMMANDS文件
cpp
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
或者编译时添加配置