clangd is a language server that can work with many editors via a plugin. Here’s Visual Studio Code with the clangd plugin, demonstrating code completion:
clangd work with vscode example
不多介绍,很牛逼就是了,对于我这种希望对代码做最精细检查的人来说非常好用
怎么安装Clangd?
对于 Debian Linux 或者 LinuxMint 用户(也包括对应的WSL用户,不再赘述)来说,输入
CompileFlags: # Tweak the parse settings Add: [-xc++, -Wall] # treat all files as C++, enable more warnings Remove: -W* # strip all other warning-related flags Compiler: clang++ # Change argv[0] of compile flags to clang++ clangd emulates how clang would interpret a file. By default, it behaves roughly as clang $FILENAME, but real projects usually require setting the include path (with the -I flag), defining preprocessor symbols, configuring warnings etc.
Often, a compilation database specifies these compile commands. clangd searches for compile_commands.json in parents of the source file.
This section modifies how the compile command is constructed.
Add
List of flags to append to the compile command.
Remove
List of flags to remove from the compile command.
If the value is a recognized clang flag (like -I) then it will be removed along with any arguments. Synonyms like --include-directory= will also be removed. Otherwise, if the value ends in * (like -DFOO=*) then any argument with the prefix will be removed. Otherwise any argument exactly matching the value is removed. In all cases, -Xclang is also removed where needed.
Example:
Command: clang++ --include-directory=/usr/include -DFOO=42 foo.cc Configuration: Remove: [-I, -DFOO=*] Result: clang++ foo.cc Flags added by the same CompileFlags entry will not be removed.