https://github.com/boocs/unreal-clangd
- Quick Start Guide
- Warnings Before Use
- About
- Requirements
- Older Unreal Versions
- Extension
- Extension Installation
- Creating a Unreal Clangd Project
- Unreal Source support
- Info
- Code Completion
- Updating Compile Commands
- Fixes
- Auto Include
- Auto Parameter Hints
- Inlay Hints
- Clang Tidy
- Go to Symbol in Workspace
- Reinstall Without Overwrite
- Uninstalling
- Full Source Project
- Compiler Path
- Help
- Known Issues
- Release Notes
- More Info
This is generally correct, when using non-full source, but your situation could be different.
- Read the Requirements section of the full Documentation
- Different Unreal Engine versions require different LLVM versions(Unreal 5.3 requires LLVM 16.0.6)
- Click the extensions icon
- Click the ellipsis (3 dots)
- Choose Install from VSIX...
- Ignore any VSCode warning messages (should go away after creating a project)
Linux:
In the next step(project creation), File Dialogues will spawn behind VSCode(known bug)
-
Code Completion/completionHelper.cpp is the heart of the extension. It's how you get Unreal symbols into code completion. See Section
-
Like other Intellisense, you must wait for a file to load before using code completion See Info Bar section
- Still pretty fast!
-
Weird Virtual function code completion behavior See Section
-
This version
does have brace initialization
completion!Note:
This is because we're using an updated clangd version
-
After installing the clangd extension(not this extension) it might ask you to automatically download and install the latest LLVM/clang/clangd.
Make sure to choose No to this.
Unreal doesn't work with some versions of LLVM/clang/clangd.
-
Some delegate function names wont show up correctly with code completion because of macro expansion
- This extension has a fix that is enabled by default
- See this section for more info
-
The clangd extension doesn't have Auto Parameter Hints.
- This extension has a fix that is enabled by default
- If you disable this setting you can always use the keyboard shortcut
- See this section for more info
-
Clangd has an option to
bundle
code completion choices that have the same name. This optionshould not be used
and is automatically disabled with this extension.- Bundle setting causes completions to be wrong (e.g. template functions)
- Bundle setting doesn't work with VSCode's deprecated strikethrough setting
-
This extension deletes/creates a compile_commands.json in the parent Unreal Engine directory and then copies it over to the project.
- Current Native Intellisense options doesn't do it this way
-
clangd intellisense currently uses 'no precompiled headers' mode (
Will work with pch projects!
) -
Popup dialogs use systems sounds. Most Operating Systems allow you to adjust System(OS) sounds without affecting overall sound volume.
-
Just like Microsoft's C++ extension, with clangd the UPROPERTY type macros don't work with code completion for their parameters.
-
clangd's Intellisense cache will be stored in your project's .vscode/unreal-clangd/cache folder
-
With both clangd extension and Microsoft's C++ extension installed you might get this window pop up.
-
Ignore this window. It will go away soon
note:
You should still use Microsoft's C++ extension for it's Building/Debugging ability
-
Your file dialogues might spawn behind the VSCode window.
-
This was tested with Ubuntu 22.04
-
This also includes a fix for my Ubuntu 22.04 setup
- This fix is in the .clangd cfg file (added include directory)
- Your version of Linux may or maybe not need this fix
Nov 2024
: Had trouble installing LLVM 18 for Unreal 5.5 (Ubuntu 22.04)
- Found this to work
- Make sure you don't have an
llvm.sh
file already in the directory you have open. The file you download won't overwrite the file already in your directory. It will name it something else. - This will install LLVM 18.1.8 (
for Unreal 5.5, make sure to install the correct version for your version of Unreal
) - Epic recommends 18.1.0
- In a perfect world, patch update versions wouldn't matter
- For me, it does seems to work fine but you could have problems. You can always build from source if you want the specific 18.1.0 version.
Here's the instructions
:
- wget https://apt.llvm.org/llvm.sh
- chmod +x llvm.sh
- sudo ./llvm.sh 18
- This extension has a setting that lets you set the
architecture
UBT flag - You can try setting this to
arm64
- You might not need this and is only provided for things to try in case it's not working
- note: Do this before creating your project
This extension creates the files and config settings needed to get clangd working with Unreal Engine 5.2+
This doesn't run automatically. You must run a command to create the configs.
Windows and Unreal 5.2+(non Full Source
) have been tested with:
- First Person template (Windows/Ubuntu 22.04)
- This does have 'fake' errors but are fixable if you add required include files to the top of certain .cpp files
- See this section for more info
Mac
will have to be tested by other users.
Linux
: Tested with Ubuntu 22.04 using FPS Template
- After clangd parses your file, you open, you'll get:
- Quick/Snappy code completions
- No weird slow Header file code completions
- Uses 'non pch' mode which can warn of headers that should be included
- Auto include is enabled by default which automatically pastes the correct include for any symbols you code complete
- For headers this is automatically disabled as it doesn't make sense for headers. see section
- Adds auto parameter hints
- Fixes Delegate function completions
- Includes a basic clang format file which can be modified, greatly, to your liking
- If enabled, includes a basic clang tidy(linter) cfg file
- Off by default because you can't indiscriminately fix Unreal code with this
- Some warnings it gives should not be fixed and the warnings themselves should be disabled!
- See the clang tidy section for more details
- This extension has an uninstall command which will remove the 'extension created' files and settings
- Unreal Engine v5.2+
- Unreal project created for VSCode
- Requires specific LLVM/clang/clangd versions!
- https://dev.epicgames.com/documentation/en-us/unreal-engine/hardware-and-software-specifications-for-unreal-engine?application_version=5.5
- Make sure to select correct Unreal Engine version (the link goes to UE 5.5)
- Requirements are only posted after a full release of UE. For Beta/Preview releases you'll have to test clang versions
- VSCode clangd extension (Do not let clangd extension auto install LLVM)
- Microsoft C++ extension for its
Building/Debugging
capability
Note:
Read below for specific Windows, Mac, and Linux requirements
note:
Versions for these are usually different for each release.
https://docs.unrealengine.com/5.3/en-US/hardware-and-software-specifications-for-unreal-engine/
-
Make sure to choose the correct Engine version in the documentation (the link above is for UE 5.3)
-
You still need XCode for it's libraries(See link above)
-
Does XCode come with clang++,clangd,clang-tidy, and clang-format? Use that version
- Else download the clang(LLVM) version specified in the
Linux
section of the above link - For Unreal 5.3 it would be LLVM 16.0.6
- For Unreal 5.5 it would be LLVM 18.1.0
- Else download the clang(LLVM) version specified in the
-
Nov 20224
Add new setting: "unreal-clangd.creation.MacFileLanguage"- This allows you to change the File Language from C++ to Ojbective C++
- Git user szabot0412 said chaning the language to Objective C++ fixed his red squiggles
- If more people confirm this then I might change Objective C++ to default file language
- Windows users should use the Linux clang(LLVM) version requirement
- Make sure you select the correct Unreal Version for the Docs
- Different Unreal versions require different LLVM versions
- https://dev.epicgames.com/documentation/en-us/unreal-engine/hardware-and-software-specifications-for-unreal-engine?application_version=5.5
- Download clang/clangd from https://github.com/llvm/llvm-project/releases/
- Filename will be LLVM-(version)-win64.exe (e.g. for UE 5.5.#, the filename will be LLVM-18.1.0-win64.exe )
- Remember if not using UE 5.5.# the LLVM version will be different
note:
For best Unreal compatibility install LLVM in the default directory.
-
Visual Studio Build Tools 2022
- Download here: https://visualstudio.microsoft.com/downloads/
- Scroll down to Tools for Visual Studio and download
"Build Tools for Visual Studio 2022"
- Scroll down to Tools for Visual Studio and download
- Direct Link https://aka.ms/vs/17/release/vs_BuildTools.exe
- Download here: https://visualstudio.microsoft.com/downloads/
-
Note:
Different versions of Visual Studio Build Tools 2022 are required
It's very easy to install different versions with the Visual Studio Installer.
-
Open the Visual Studio Installer and click Modify on Visual Studio Build Tools 2022.
-
Now go to Individual components
-
Scroll down to all the listings for MSVC v143 - VS 2022 C++ x64/x86 build tools
-
If you haven't created your Unreal project yet you can skip step 5
-
For existing Unreal projects, run this extension's commands called:
Update Compile Commands file
- This command is the same command that also refreshes your project
-
- dotnet-runtime-6.0
- dotnet-sdk-6.0 (Only needed for seeing UBT logs when updating compile commands)
Nov 2024
: Had trouble installing LLVM 18 for Unreal 5.5 (Ubuntu 22.04)
- Found this to work
- Make sure you don't have an
llvm.sh
file already in the directory you have open. The file you download won't overwrite the file already in your directory. It will name it something else. - This will install LLVM 18.1.8 (
for Unreal 5.5, make sure to install the correct version for your version of Unreal
) - Epic recommends 18.1.0
- In a perfect world, patch update versions wouldn't matter
- For me, it does seems to work fine but you could have problems. You can always build from source if you want the specific 18.1.0 version.
Here's the instructions
:
- wget https://apt.llvm.org/llvm.sh
- chmod +x llvm.sh
- sudo ./llvm.sh 18
- dotnet-runtime-6.0
- clang
- dotnet-sdk-6.0 (Only needed for seeing UBT logs when updating compile commands)
I probably won't release this for older Unreal versions. 5.0.0 had many compile command bugs(at least for Windows). These bugs are fixable just by using the clangd cfg so 5.0.0 would work with clangd...
The other reason was a Unreal design change. 5.0.0 uses compile commands while 5.1.1+ uses compile commands + response files. It would require a little bit different extension code.
unreal-clangd.createUnrealClangdProject
: Creates all files and settings for clangd to work with an Unreal projectunreal-clangd.updateCompileCommands
: Creates/Updates the compile commands file which clangd uses for Intellisense. Created in project/.vscode folder. (Extension will, in most cases, prompt you to update automatically)unreal-clangd.uninstall
: Uninstalls Unreal-clangd files and settings (It will prompt you before deletion)unreal-clangd.fixIntellisenseFiles
: Runs the quote fix for paths in response files (Will auto run if setting is true)unreal-clangd.tidyNoLintCurrentLine
: Removes clang Tidy linting on current line- Modifies code
- Also found in context menu
unreal-clangd.tidyNoLintNextLine
: Removes clang Tidy linting on next line (Modifies code)- Modifies code
- Also found in context menu
unreal-clangd.tidyTEST
: Pastes code that produces clang Tidy warning (Modifies code)- Modifies code
- Also found in context menu
unreal-clangd.IntellisenseType
: This is always set to 'Native' even if switched (for now)
unreal-clangd.native.minutesTillIntellisenseFilesAreOld
:- Can cause circular run of Update Compile Commands if set too low. You can also run Update Compile Commands manually if you run into trouble with it being too high.
unreal-clangd.native.code-workspaceFileBackupSettings
:- Array so you can specify which settings to backup in your *.code-workspace file when the native
Update Compile Commands
is run. This runs UBT's 'refresh project files' command that will overwrite your *code.workspace file. Some settings will automatically be backed up and are listed in your settings.
- Array so you can specify which settings to backup in your *.code-workspace file when the native
unreal-clangd.compileCommands.execType
: Task | Debug- Debug requires Microsoft C# extension which lets you see UBT logs
unreal-clangd.compileCommands.platform
: Leave blank for auto detectionunreal-clangd.compileCommands.architecture
: Most users can leave this blank- Mac M1/M2 users should set this to arm64 (not tested)
unreal-clangd.creation.overwrite
: Allows overwriting of project. note: You don't need to set this manually- "partial": Never overwrite but create files/settings that haven't been created
- "full": Overwrite everything
unreal-clangd.creation.completionHelper
: true(default) Needed to make code completion functional. Creates a completionHelper.cpp and adds it to compile_commands.jsonunreal-clangd.creation.completionHelperMP
: true(default) Also add UnrealNetwork.h(multiplayer) to completionHelper.cppunreal-clangd.creation.tidy
: false(default) creates a clangd tidy file, during creation command, if true (see clang tidy section)unreal-clangd.creation.MacFileLanguage
: Can switch Mac file language support to C++ or Objective C++
unreal-clangd.editor.parameterHints
: Automatically pops up param hints windows after function name completion- disabled:
- needed:
(default)
Only on functions that require parameters - all: Will also work on functions with only Default Parameters and Empty parameters
- This setting has a side affect of moving the cursor inside the function parentheses
- Also activates when copying and pasting a function
unreal-clangd.fixes.intellisenseFiles
: Enables/disables Change or fix intellisense files when needed. (This will auto fix whenever it detects compile command changes)unreal-clangd.fixes.delegateFunctionCompletions
: Some delegate functions completions aren't correct because of macro expansion. This will fix the completion when detected.- See this section for more info
unreal-clangd.fixes.focusSuggestionDelay
: Fixes code completion selection not happening with parameter hints. Default 350 see section
unreal-clangd.completion.openCompletionHelperOnStartup
: Opens completionHelper.cpp on startup. 'Hack' to add Unreal 'macro' symbols to code completion.unreal-clangd.completion.completionHelperInfoOnStartup
: You can disable warning message about completionHelper.cpp on startup
This extension is installed manually with a VSIX file downloaded from this github
To install the VSIX file in VSCode do the following:
- Click the extensions icon
- Click the ellipsis (3 dots)
- Choose Install from VSIX...
-
Note:
The default is not seeing the debug info when creating Intellisense files. If you run into any problems, you can change this with this setting:Note:
Weirdly Debug was faster than Task when testing a Full Source project
- You may see this window popup because you have clangd and Microsoft extension installed at the same time.
Here's a movie
of the installation process. Step by Step
instructions are below the movie:
create-unreal-clangd-project.mp4
-
Make sure the correct clangd version is installed and you have all the requirements
-
Build your project without errors
-
Inside VSCode press F1 and search for
unreal clangd
- It should list all the commands this exention has
-
Choose the
Create Unreal clangd project
command: -
The first thing that will happen is it will add settings to remove the extension conflict warning. It will then reload the VSCode window and continue installation.
-
Because we haven't created a compile commands file yet it'll ask you to do so:
-
After choosing Yes, at the top of VSCode you'll be given a list of Build Targets to choose from. The
Editor suffix
Build target is usually the best choice and the one that should be at the top of the list: -
A window will pop up showing you the creation options you have set:
-
After a file dialogue will appear so you can select your clangd executable.
For example, on
Windows
, my clangd executable is found at: C:\Program Files\LLVM\bin\clangd.exeOn
Ubuntu
it was found at: /usr/lib/llvm-16/bin/clangd (If installing forUnreal 5.3
)On
Arch Linux
installing theclang
package it was found at: /usr/sbin/clangdUbuntu/Linux:
Your file dialogue might spawn behind the VSCode window: -
And finally it'll ask you to reload the VSCode window:
-
After creating and reloading your project you might get this window pop up.
-
Intellisense should now start working!
- Remember to wait for your file to be parsed by clangd
-
Your project should not have any Intellisense errors
- Of course if you have clang Tidy enabled you may have a lot of warnings
-
If your project has errors it could be because you have missing include files in your cpp files
- This is because we're using the non-pch mode for Intellisense
- See this section for an example
-
It's also possible, if you have errors, that .clangd isn't setup properly
If you noticed above, in the Creating a Unreal Clangd Project section, the command line option -tidy
was disabled. You may not want to mess with clang Tidy at first. This will show you the easiest way to install the clang tidy cfg on a later date.
-
First open your project's .vscode/settings.json file
-
Add these settings to the settings.json file
"unreal-clangd.creation.tidy": true
-
Press F1 and run the Create Unreal Clangd Project command again
-
Go through the creation process again but choose the 'Partial' install option
Note: If you choose the
Partial
install option it shouldn't overwrite any other files and settings. -
The clang tidy linter should now work!
-
Oh no!
-
See the clang tidy section for more info.
Starting with extension version 2.6.0, it now support Unreal Source files
-
Requirements:
Must have created a VSCode project using Unreal/UBT- This is because this extension uses the files that were created for your project
-
When creating a project it will also create a .clangd file in the Unreal directory(only if there isn't one there)
-
It will never overwrite a clangd file in your Unreal directory
-
You can also use the command:
Create Unreal Source Support
if you want to only create a Unreal Source support project -
This dynamically creates a compile commands file based on the response files that are created when you created your Unreal project
Note:
This extension turns off errors for .cpp files for Non-Full source Unreal Engine Files
- This is because some .cpp files have special include macros
- The files required for these include statements don't exist in Non-Full source projects
- This shouldn't affect anything
This won't affect your project files
. Just Unreal Source files.- This is feature is found in the .clangd file in the Unreal Engine parent directory so it can easily be removed if you want
Click the console 'OUTPUT' tab and change the top right drop down to 'unreal clangd':
Lets you Add/Remove Intellisense compile flags that clang uses, among other things. See clangd docs.
note: A lot of functionality was added with clangd-14 so won't work wth earlier versions
The clangd extension will take over formatting of your C++ documents.
The .clang-format file will be located in your project directory.
This extension creates a bare minimum format file that makes code look pretty good.
Note: This can be highly customized. There are even websites that will generate .clang-format files to your liking.
For more format settings info: https://clang.llvm.org/docs/ClangFormatStyleOptions.html
Used for the C++ linter. You can see the docs here
Check the Tidy Section for more info.
VSCode's bottom info bar can tell you info about clangd's opened file status.
It will show Parsing and Indexing.
-
When you first open a file you need to wait for these to finish before using code completions.
-
When you include or auto include a header file you also need to wait
-
You can also tell a file is done parsing because the #includes will be underlined
- Note: Indexing might not be done yet though. I would wait for that as well.
This contains clangd settings for your project. You can change these from the default if you like.
The file is located in your project's parent folder.
Warning
: Using the Unreal Engine's Refresh Visual Studio Project
or Generate Visual Studio Project files
command will overwrite this file. See this section.
No Unreal source headers are added to your project's compile_commands.json. So how do we get Unreal symbols for code completion?
I've come up with a solution called completionHelper.cpp
It contains includes that have a lot of the more popular Unreal class and function symbols for code completion. It also gets added to compile_commands.json every time it gets updated.
note: Please let me know if any other headers should be included by default
There is a problem though. Macros don't show up and Unreal uses a lot of macros.
Here is an example from UnrealNetwork.h:
I've come up with another solution. If we open completionHelper.cpp at the start of VSCode
, and let clangd parse the file, Macro symbols do load and are available to code completion!
This feature is enabled by default
If we add plugins we need the ability to also add the plugin's header symbols into clangd's code completion.
Here's a workflow I've come up with:
-
Let's say we've added the plugin
EnhancedInput
to your project's *.build.cs -
Once we do so, we need to
update compile_commands.json
using the extension command. Doing this should include the plugin's path in your include paths. -
Updating compile_commands.json should automatically reload VSCode. completionHelper.cpp should now be open.
-
Once completionHelper.cpp loads, we can now type a temporary include to try to find that path the holds the plugin's header files. The path is in code completion because of our previous steps.
-
When you hover over the file path it'll show you how to open that file:
-
Follow the link to open the file and don't switch away from the file.
-
Now we run the extension's command to Add Headers:
-
Because we had the plugin's file open, the folder chooser dialog should have the correct folder already open:
Note:
Ubuntu/Linux users see here if file dialogue doesn't appear. -
If the file dilogue doesn't open to the directory of the file you currently have open, you can always copy the plugin's file directory from VSCode's left panel and paste it into the dialogue:
-
When you choose the folder, the header files are copied to completionHelper.cpp
note: I manually removed the temporary #include from the previous step
-
In the above example, it copied 18 header paths. Try to copy only the headers you need. Don't copy parent directories which would include hundreds of headers.
When you include the return type you won't get code completion (note: the completion shown is a user made snippet):
Leave out the return type to get completions:
The snippet inline setting doesn't appear to work with clangd. User snippets will be found at the bottom of the code completion list. You could use the Top setting, for snippets, but many would find that annoying.
If you're looking for snippets you can press the Up Arrow key to get to the bottom of the code completion list.
You can change the font size of the code completion window:
-
Open the
*.code-workspace
file in your project's parent directory -
Find the
"editor.suggestFontSize"
setting and set it to a setting that lets you see the parameters of functions in the code completion window.Note:
The "editor.suggestFontSize" setting should already be set to0
in the *.code-workspace file. The zero setting sets it to the same font size as the editor.
This extension should automatically detect when you need to update compile commands and ask you if you would like to update.
It should auto detect when:
- Adding a new .h or .cpp file
- Running a task with the words Rebuild or Clean
Note
: If you add a plugin to your *.build.cs file, you'll need to run the command manually.
Run extension command 'Update Compile Commands' manually to fix fake red squiggles that may rarely happen.
This was causing problems with the Windows config. Paths with spaces weren't being included so would cause errors. This fix, which is enabled by default
, will try to fix all the paths without quotes.
Clang does macro expansion causing functions, that use macros, to have incorrect code completion. When code completing delegates, some of the function names might appear like so:
-
These are
real/legit
function names -
You'll probably use some of these functions in most of your projects!
-
If you complete the completion, the wrong functon will be used
-
This extension has a fix that is
enabled by default
but you can disable it like so: -
Without the fix enabled, the incorrect function is completed:
-
With the fix enabled, the correct 'function' is used:
When typing in function parameters, completion choices wouldn't show.
The setting editor.suggest.snippetsPreventQuickSuggestions was to blame.
We set this to false in the settings.json file in your project's .vscode folder.
Thanks to Mark at stackoverflow for fix!
Nov 2024
: Had trouble installing LLVM 18 for Unreal 5.5 (Ubuntu 22.04)
- Found this to work
- Make sure you don't have an
llvm.sh
file already in the directory you have open. The file you download won't overwrite the file already in your directory. It will name it something else. - This will install LLVM 18.1.8 (
for Unreal 5.5, make sure to install the correct version for your version of Unreal
) - Epic recommends 18.1.0
- In a perfect world, patch update versions wouldn't matter
- For me, it does seems to work fine but you could have problems. You can always build from source if you want the specific 18.1.0 version.
Here's the instructions
:
- wget https://apt.llvm.org/llvm.sh
- chmod +x llvm.sh
- sudo ./llvm.sh 18
-
Nov 20224
Add new setting: "unreal-clangd.creation.MacFileLanguage"- This allows you to change the File Language from C++ to Ojbective C++ (
during clangd project creation
) - Git user szabot0412 said changing the file language to Objective C++ fixed his red squiggles
- If more people confirm this then I might change Objective C++ to default file language for Mac users
- Open up your .clangd files in your project parent directory and Unreal Source parent directory
- Change this line under
Add:
Change to this:- -xc++
- -xobjective-c++
- This allows you to change the File Language from C++ to Ojbective C++ (
clangd has an cool auto include feature.
When adding a symbol(e.g. class) to your code, it will automatically add the #include for the symbol!
- The white dot, to left of completion symbol, shows what completions will also do auto include
- You must wait, see info bar section, for clangd to process the symbols in the new header.
auto-header-includes.mp4
This feature is enabled by default
To disable:
- Open your (ProjectName).code-workspace file (In your project's parent directory)
- Change this line:
"-header-insertion=iwyu",
- To this:
"-header-insertion=never",
Auto include doesn't make much sense for header files. You usually forward declare. It also does some silly stuff like including the header for UPROPERTY.
Auto include for headers is default disabled
You can enable it for header files in this extension's settings:
note: I strongly recomment not to do this
There is a side effect with disabling Auto Include for headers that can be easily solved. See next section below.
In a rare case, you may want to paste an #include line in your header file.
If you have Auto Include disabled for header files, then pasting an #include line will also be removed.
- To fix, just use Undo (Ctrl-Z) to get your #Include line back
Some includes need to be done with the quick fix feature.
The source file doesn't know about the UCharacterMovementComponent* returned by GetCharacterMovement()
If we hover the cursor over the red squiggle a window will pop up:
We can choose 'Quick Fix...' to get another pop up to add the correct header file:
What to do when auto include fails?
You can temporarily
type the class name to bring up the completion window:
Press Enter key to finish the completion and auto include the header
After clangd processes the new header your code should now work!
Note: You can also temporarily
type a symbol on a blank line and finish the completion to get the auto include to happen. You don't need to do it inside your code like the above example.
Clangd parameter hints don't trigger automatically but this extension enables this functionality by default
.
If you disable this setting, you can trigger parameter hints manually using a VSCode shortcut.
Search VSCode keyboard shortcuts for your keybinds.
If you want to change the Auto Parameter Hints setting you can do so:
With the setting enabled, you wont have to use a keyboard shortcut to get parameter hints:
If you use the 'all' setting, functions with only default parameters and empty parameters will also trigger the auto parameter setting. Some side effects include:
- The cursor must be moved for these particular functions
- Copy and pasting a function with an empty parameter will trigger the cursor move and parameter window
The 'needed' setting value will not have these side effects
Auto Parameter Hints doesn't work with template functions. This could be a clangd version problem.
You must use the keyboard shortcut to trigger them when you get to the non-template parameters.
Check above on how to see your keybind for parameter hints. The default keybind, for Windows, is Ctrl+Shift+Space.
Note: Inlay Hints are new to Unreal because of the updated clangd version.
Inlay Hints show the variable names of function parameters and more.
On:
Off:
- Open the
.clangd
file in your project's parent directory - Under
InlayHints:
change Enabled to No like so:InlayHints: Enabled: No
To Adjust Color:
- Open your *.code-workspace file in your project's parent directory
- Adjust these settings that should already be there:
"workbench.colorCustomizations": { "editorInlayHint.foreground": "#a2a2a2c0", "editorInlayHint.background": "#00000000" }
Note:
These colors aren't the default since the default colors didn't look good
To Adjust Size:
This setting isn't in the *.code-workspace file but you can add and adjust it to your liking:
"editor.inlayHints.fontSize": 12
Clang Tidy is off by default. This is because there's a lot of ambiguity that applies to what clang tidy code Checks to enable/disable.
I've created a separate guide to clang tidy:
https://github.com/boocs/Unreal-clang-tidy-guide
Note
: In the settings of this extension you can enable a Tidy setting so that whenever you create a project it will automatically create a .clang-tidy file.
If you make use of this VSCode menu item, there is a clangd setting you might want to look at. Open your project's *.code-workspace cfg file in your project's parent directory. Change the setting:
-limit-references=2000
The default for this setting is 2000.
You can set it to 0 for unlimited
or set it to whatever you like.
Note: I don't know what performance impact this has.
This is now easier than early extension versions.
Just run the Create Unreal Clangd Project command again using the Partial
option when prompted
Because we chose the Partial
options it shouldn't overwrite any other files and settings.
Run the unreal-clangd.uninstall
command to uninstall the files and settings created by this extension.
It will show you what files will be deleted and if you want to delete them permanantly or send them to the trash.
It will ask which settings to delete and if you want to delete the settings for the project only or globally as well.
Here's a movie
of the process:
uninstall-unreal-clangd-project.mp4
A full source Unreal project seems to work but does have some quirks.
It seems when updating compile commands it takes a long time when using the task
exec type instead of the debug
exec type. This is counterintuitive so not sure what's going on there.
You can see how to change
the default task to debug
using the Exec Type setting here
If you change the Exec Type setting to debug
you'll need to install the Microsoft C# extension
After installing the C# extension you may get this window.
When this windows pops up choose "Do not load any":
Note:
If you already set a default, then the setting should be found in your project's *.code-workspace file
You can remove it if it's not working correctly.
"dotnet.defaultSolution": "UE5/Engine/Plugins/ScriptPlugin/Source/Lua/Lua.sln"
Because we're using Full Source clangd indexing took longer:
- It took less than 3 minutes
- It only happens after you first install. Subsequent indexing will be faster.
You can auto set your compiler path when creating a project using this setting:
Note:
Most people wont need to set this
Windows:
note:
This is no longer possible with Unreal 5.3. You need to install LLVM 16.0.6 in it's default folder because Unreal Build Tool needs to see the LLVM path and won't be able to in a nonstandard directory.
If you're not Building Unreal with clang(only using it for Intellisense) and you're using both Unreal 5.1.1 and 5.2.0 you could install LLVM 15 in a non-standard directory. clangd 13.0.1 doesn't have the ability to change the compiler path. LLVM 15.0.1 does though.
Unreal will use clang 13.0.1 because it's in the default path when your really want 15.0.1 with Unreal 5.2.0
Linux:
Unreal usually adds their own clang path. You can change this if you like.
- Open your
.clangd
file in your project's parent folder - Add
Compiler:
underCompileFlags:
like so:CompileFlags: Add: - -D__INTELLISENSE__ Compiler: C:\Program Files\LLVM-15\bin\clang-cl.exe
- Note: Your path will probably be different
You can post bugs or ask questions here:
https://github.com/boocs/unreal-clangd/issues
-
Adding code or a space, in a header file, anywhere above the GENERATED_BODY macro will cause red squiggles. This is because the GENERATED_BODY macro uses the __LINE__ preprocessor macro.
You'll need to Build your project to get rid of the red squiggles.
-
Code completion sometimes doesn't work
I've run into this bug. Pressing control+space (Windows) will manually activate Code Completion. Look up your keyboard shortcut for your system.
-
You can close/reopen file to refresh Intellisense.
You can also try typing a space, wait half a second, and delete the space.
-
If you add a plugin to *.build.cs you'll need to run the extension command to Update Compile Commands.
- See this section for more info
Just like the Microsoft C++ extension, parameter code completion for UPROPERTY(and others) macro doesn't work.
I created an extension for this:
https://github.com/boocs/UE-Reflection-Func-Params
Warning
: Using the Unreal Engine feature to Refresh Visual Studio Project
or Generate Visual Studio Project files
will overwrite your *.code-workspace file.
This file contains your project's clangd settings!
See this section on how to easily reinstall without overwriting other settings.
When creating a project it pulls all the Source folders from the compile commands file.
If you add a source folder(e.g. Plugins) after the fact, then Intellisense wont work for this folder. You can fix this easy by adding the folder name to the .clangd file like so:
You'll also need to run the Update Compile Commands command:
File dialogues currently spawn behind VSCode:
The extension now detects
that the Microsoft C++ extension is installed and will auto set correct settings on startup or reload.
Some might not know you can do this. With how function name code completions work, you may need to do this to see the parameters.
- Just grab and drag the edge of the code completion window like you normally do.
See CHANGLELOG
This is the setting that can crash clangd (note
: This should be tested with later clangd versions to see if it has been fixed)
readability-static-accessed-through-instance
This is automatically disabled when you create a project with tidy enabled.
Here is more info about the crash:
// Code that crashes when clang tidy setting readability-static-accessed-through-instance is enabled
// This code is found in Lyra's LyraCameraComponent.cpp and LyraPlayerCameraManager.cpp
DisplayDebugManager.SetFont(GEngine->GetSmallFont());
This extension uses the non-pch version of Intellisense which will show missing include files that will show up as 'fake' errors on pch verson projects.
The FPS Template that Epic provides has some of these errors.
To fix this you just need to include some header files:
For *Character.cpp
#include "Engine/LocalPlayer.h"
#include "GameFramework/PlayerController.h"
For TP_WeaponComponent.cpp
#include "Animation/AnimInstance.h"
#include "Engine/LocalPlayer.h"