A minimalistic tool to make Clangd VSCode extension work smoothly with Unreal Engine projects. The extension:
- Automatically generates Clang compile commands file using UBT and copies it in the project directory.
- Updates generated header files using UBT on demand to prevent Clangd static analysis errors.
- Generates .clangd and .clang-format files to optimize code formatting and static analysis for Unreal Engine projects.
- Identify Clang Version: Visit the Unreal Engine Release Notes for your specific version. Search for the "IDE Version the Build farm compiles against" section to find the LLVM Clang version suggested by Epic. If you have multiple engine versions installed, use the LLVM Clang version corresponding to the latest UE version on your machine. Then download and install it from https://github.com/llvm/llvm-project/releases
- Install Clangd: Install the official clangd extension for VS Code.
- Install This Extension: Download and install this extension (
.vsix). - Unreal Editor Configuration:
- In Unreal Editor, go to Editor Settings > General > Source Code.
- Set Source Code Editor to Visual Studio Code.
- Select File > Generate Visual Studio Code Project.
- Initialize: Open the generated
.code-workspaceproject in VS Code and run the command:UE Clangd: Setup Project.
If you add, remove, or rename source files:
- Run
UE Clangd: Refresh File Changes (New/Move/Rename). - This triggers the generation of a new compile database and copies it to the project root.
If you modify a header file (especially above the class declaration) and see false red squiggles:
- Run
UE Clangd: Refresh Header Changes (Fix False Errors). - This executes UHT to sync generated headers and restarts the
clangdserver to pick up the changes.
ueClangdHelper.generateConfigs: (Default:true) Generates.clangdand.clang-formatfiles in the project root.ueClangdHelper.syncCompileCommands: (Default:true) Automatically mirrors the engine-generated JSON to the project directory.
- Unreal Engine 5.X: Tested on UE 5.5+.
- VS Code Workspace: The project must be opened via the
.code-workspacefile generated by Unreal to correctly resolve Engine and Project paths.