3 Star 0 Fork 0

mirrors_clangd/vscode-clangd

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

clangd

clangd helps developers write, understand and improve C/C++ code by providing:

  • code completion
  • compile errors and warnings
  • go-to-definition and cross references
  • hover information and inlay hints
  • include management
  • code formatting
  • simple refactorings

Full documentation for clangd is at clangd.llvm.org.

Setup

clangd server

The extension requires the clangd language server. You will be prompted to download it if it's not found on your PATH. (Automatic installation is possible on x86-64 Linux, Windows, and Mac).

If you have an old version of clangd installed on your system already, you can run "Check for clangd language server update" from the command palette.

Project setup

clangd is based on the clang C++ compiler, and understands even complex C++ code. However, you must tell clangd how your project is built (compile flags). A compile_commands.json file can usually be generated by your build system (e.g. with CMake, by setting -DCMAKE_EXPORT_COMPILE_COMMANDS=1).

See Project Setup in the clangd documentation for details and alternatives.

The clangd server also supports a number of feature customizations using its config file.

Features

Code completion

Suggestions will appear as you type names, or after . or ->. Because clangd uses a full C++ parser, code completion has access to precise type information.

Code completion

Errors, warnings, and clang-tidy

Code errors are shown as you type (both as red squiggle underlines, and in the "Problems" panel). These are the same as produced by the clang compiler, and suggested fixes can automatically be applied.

Error with fix

Most clang-tidy checks are supported (these can be enabled using a .clang-tidy file).

Cross-references

Go-to-definition and find-references work across your code, using a project-wide index.

Cross-reference list

Press Ctrl-P # to quickly navigate to a symbol by name.

Hover and inlay hints

Clangd can describe almost any entity if you hover the mouse (or press Ctrl-KI).

Hover and inlay hints

Inlay hints for parameters and deduced types can be shown temporarily or permanently (the editor.inlayHints.enabled setting controls this).

Include management

Code completion works across your codebase and adds #include directives where needed. The shows includes that will be inserted.

clangd can suggest inserting missing #includes, where they cause errors. It can warn on unused includes.

Fix inserts include

Formatting

clangd uses the clang-format engine. You can format a file or the selection. When "Format on Type" is enabled in the settings, pressing enter will cause clangd to format the old line and semantically reindent.

Format-on-type

The style used for formatting (and certain other operations) is controlled by the project's .clang-format file.

Note that if you prefer to use something other than clangd for formatting, you can choose a different formatter with the "editor.defaultFormatter" setting.

Refactoring

clangd supports some local refactorings. When you select an expression or declaration, the lightbulb menu appears and you can choose a code action.

Extract variable code action

Current refactorings include:

  • extract variable/function
  • expand auto types and macros
  • use raw strings
  • rename (bound to <F2>, rather than a contextual code action)

Bugs/contributing

clangd is part of the LLVM project.

If you'd like to help out, reach out to clangd-dev@lists.llvm.org

If you've found a bug in this extension, please file it at https://github.com/clangd/vscode-clangd/issues. If you've found a bug in clangd, please file at https://github.com/clangd/clangd/issues.

The MIT License (MIT) Copyright (c) 2019 The LLVM Developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

暂无描述 展开 收起
README
MIT
取消

发行版

暂无发行版

近期动态

接近4年前创建了仓库
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_clangd/vscode-clangd.git
git@gitee.com:mirrors_clangd/vscode-clangd.git
mirrors_clangd
vscode-clangd
vscode-clangd
master

搜索帮助