Kylin Clangd
Kylin Clangd is a fork of vscode-clangd, designed to provide an enhanced C/C++ development experience. It includes all the features of the original extension with additional improvements and integrations.
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.
Kylin Clangd Features
Bundled Clangd Server
This extension comes with a bundled and modified clangd language server, so you don't need to install it manually. It works out of the box.
Note: The bundled language server is currently available only for linux-x64, linux-arm64, and windows-x64 platforms.
Enhanced Project Setup
- CMake Tools Integration: Automatically retrieves the compile database path from the CMake Tools extension.
- QMake Tools Integration: (Linux) Supports getting the compile database directory from the QMake Tools plugin.
Configuration Management
- Quick Config Creation: Easily create
.clangd, .clang-tidy, and .clang-format files in your workspace.
- YAML Support: Provides auto-completion, validation, and formatting for clangd configuration files (.clangd, .clang-tidy, .clang-format).
- New Settings:
headerInsertion: Control header insertion behavior.
enableClangTidyDiagnostic: Toggle Clang-Tidy diagnostics.
preferBundledClangd: Choose between the bundled or user specified clangd server.
Documentation
- Press
Shift+F1 to quickly jump to relevant documentation.
Setup
clangd server
The extension uses the bundled clangd language server by default. You can configure this behavior with the preferBundledClangd setting.
By setting preferBundledClangd to false, you can specify a custom clangd binary path using the clangd.path setting. If clangd is not found, you will be prompted to download it from the official releases.
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).
Integration with CMake:
This extension works seamlessly with KylinIdeTeam.kylin-cmake-tools to automatically retrieve the compile database.
For the best experience, we recommend installing the extension pack kylinideteam.kylin-cpp-pack.
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.

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.

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.

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).

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.

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.

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.

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
Kylin Clangd is a fork of the vscode-clangd project.
If you've found a bug in this extension, please file it at https://github.com/quanzhuo/vscode-clangd/issues.