# kylin-clangd **Repository Path**: openkylin/kylin-clangd ## Basic Information - **Project Name**: kylin-clangd - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2023-06-30 - **Last Updated**: 2025-11-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Kylin Clangd This is a fork of the vscode-clangd extension, aimed at making clangd work better with the CMake Tools. It is recommended to install the extension pack `KylinIdeTeam.kylin-cpp-pack`, This extension can obtain the compilation database directory from the CMake Tools extension within the pack, allowing clangd to work better. **Note:** For `linux-x64`, `linux-arm64`, and `win32-x64` platforms, this extension comes with a built-in clangd language server. You do not need to install clangd separately. Full documentation for clangd is at [clangd.llvm.org](https://clangd.llvm.org). ## Changes made to the original vscode-clangd extension - Obtain the compilation database directory from [cmake tools extension](https://marketplace.visualstudio.com/items?itemName=KylinIdeTeam.kylin-cmake-tools) - Add some settings to control the clangd server more flexibly. - `clangd.headerInsertion`: set to `iwyu` to insert include-what-you-use header, set to `never` to disable header insertion. - `clangd.enableClangTidyDiagnostic`: enable clang-tidy diagnostics. enable this option will create a `.clang-tidy` file in workspace - `clangd.useBuiltInClangdIfAvailable`: default to `true`, set to `false` to use the clangd server specified by `clangd.path` instead of the built-in one. This is useful if you want to use a newer version of clangd than the one provided by this extension. - Add a command `clangd.createClangdConfigFile` to create three files: `.clangd`, `.clang-tidy`, and `.clang-format` in the workspace folder. These files have default configurations that can be modified as needed. You can input `Create clangd configuration file` in the command palette to execute this command. - Add auto completion, schema validation for `.clangd`, `.clang-tidy` and `.clang-format` files (You must have extension `redhat.vscode-yaml` installed to enable schema validation). - `.clangd` file is used to configure the clangd server, see [clangd configuration](https://clangd.llvm.org/config) for more information. - `.clang-tidy` file is used to control the clang-tidy diagnostics, see [clang-tidy documentation](https://clang.llvm.org/extra/clang-tidy/) for more information. - `.clang-format` file is used to control the code formatting, see [clang-format documentation](https://clang.llvm.org/docs/ClangFormatStyleOptions.html) for more information. ## Feedback Please report bugs or feature requests for this extension at [Kylin Clangd OpenKylin Repository](https://gitee.com/openkylin/kylin-clangd/issues). ## Requirements + On `linux-x64`, `linux-arm64`, and `win32-x64`, clangd is built-in and no additional installation is required. + On other platforms, please install clangd manually (the newer the better). The extension requires clangd 9 or later. `.clangd` file support requires clangd 11 or later. + Please install the extension `redhat.vscode-yaml` to enable schema validation for `.clangd`, `.clang-format`, and `.clang-tidy` files. ## 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](http://clang.llvm.org/docs/JSONCompilationDatabase.html) can usually be generated by your build system (e.g. with CMake, by setting `-DCMAKE_EXPORT_COMPILE_COMMANDS=1`). See [Project Setup](https://clangd.llvm.org/installation#project-setup) in the clangd documentation for details and alternatives. ## Features ### Auto completion, schema validation for `.clangd`, `.clang-tidy` and `.clang-format` files Suggestions will appear as you type in these files, you can also press ctrl + space to bring up the suggestion list. ![Configura file support](https://gitee.com/openKylin/kylin-clangd/raw/master/doc-assets/configFile.png) ### 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](https://raw.githubusercontent.com/clangd/vscode-clangd/master/doc-assets/complete.png) ### 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](https://raw.githubusercontent.com/clangd/vscode-clangd/master/doc-assets/diagnostics.png) Most clang-tidy checks are supported (these can be enabled using a [.clang-tidy file](https://clang.llvm.org/extra/clang-tidy/)). ### Cross-references Go-to-definition and find-references work across your code, using a project-wide index. ![Cross-reference list](https://raw.githubusercontent.com/clangd/vscode-clangd/master/doc-assets/xrefs.png) 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](https://raw.githubusercontent.com/clangd/vscode-clangd/master/doc-assets/hover.png) 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](https://clangd.llvm.org/guides/include-cleaner). ![Fix inserts include](https://raw.githubusercontent.com/clangd/vscode-clangd/master/doc-assets/include.png) ### 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](https://raw.githubusercontent.com/clangd/vscode-clangd/master/doc-assets/format.png) The style used for formatting (and certain other operations) is controlled by the project's [.clang-format file](https://clang.llvm.org/docs/ClangFormatStyleOptions.html). ### 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](https://raw.githubusercontent.com/clangd/vscode-clangd/master/doc-assets/extract.png) Current refactorings include: - extract variable/function - expand `auto` types and macros - use raw strings - rename (bound to ``, rather than a contextual code action)