- Install coc.vim, e.g. with vim-plug inside
.vimrc
:
Plug 'neoclide/coc.nvim'
- Run
:CocInstall coc-clangd
- In UE4Editor
- go to
Edit - Editor Preferences - General - Source Code - Source Code Editor
and selectVisual Studio Code
- go to
File - Refresh Visual Studio Code Project
- go to
- Create a symlink from your project's root directory to
myProject/.vscode/compileCommands_myProject.json
ln -s .vscode/compileCommands_myProject.json compile_commands.json
Alternatively, you can also use YCM or Neovim's native LSP.
- Install vimspector, e.g.
Plug 'puremourning/vimspector'
- Configure debugging vimspector keybinds or simply add
let g:vimspector_enable_mappings = 'HUMAN'
to your.vimrc
. - Create a
.vimspector.json
inside of your project's root directory (simply refer to the myProjectEditor (DebugGame) entry inmyProject/.vscode/launch.json
), e.g.
{
"configurations": {
"Launch": {
"adapter": "vscode-cpptools",
"configuration": {
"request": "launch",
"program": "/path/to/UnrealEngine/Engine/Binaries/Linux/UE4Editor-Linux-DebugGame",
"args": [ "/path/to/myProject/myProject.uproject" ],
"cwd": "/path/to/UnrealEngine",
"externalConsole": true,
"MIDebuggerPath": "/usr/bin/gdb",
"MIMode": "gdb"
}
}
}
}
- Compile a debug build
path/to/UnrealEngine/Engine/Build/BatchFiles/Linux/Build.sh myProject Linux DebugGame '/path/to/myProject/myProject.uproject' -waitmutex
- Set a breakpoint (F9) and start debugging (F5) in Vim and your project will open in a new instance for debugging.
If you just wish to compile your project refer to the following entries in myProject/.vscode/tasks.json
:
path/to/UnrealEngine/Engine/Build/BatchFiles/Linux/Build.sh myProject Linux Development '/path/to/myProject/myProject.uproject' -waitmutex
For anything else building and debugging-related simply refer to tasks.json
and launch.json
in myProject/.vscode
.
I highly recommend using ue4-cli. This application is primarily used for compiling your project from the terminal but it can do a bunch of other neat things like running automation tests, generating IDE project files, cleaning your build files, and even packaging your build. It also works for UE5 if you set the engine path manually (at the time of writing, this is still a bug). I defined a function in my .zshrc
to act as a wrapper for ue4-cli which adds all of the automation that I like to have in my workflow.
When trying out this setup for UE5, I was greeted with plenty of clang errors. I was able to get an experience that is on par with vscode by modifying my compile_commands.json
. Instead of using the clang binary that ships with Unreal Engine, I would use my own clang++ (13.0.1) by simply removing the full path to UE's clang from each value in the file. Then I added -ferror-limit=0
right after clang++. Finally, I had to use C++20 (even though it is not supported by UE) to get rid of bad member function call errors.
{
"file": "/home/User/MyGame/Plugins/UEGitPlugin/Source/GitSourceControl/Private/GitSourceControlMenu.cpp",
"command": "clang++ -ferror-limit=0 -std=c++20 /home/User/MyGame/Plugins/UEGitPlugin/Source/GitSourceControl/Private/GitSourceControlMenu.cpp @/home/User/MyGame/.vscode/compileCommands_MyGame/GitSourceControl.4.rsp",
"directory": "/home/User/unrealengine/Engine/Source"
},
If coc is telling you that clangd is missing input files, try the following:
- Inside of your
compile_commands.json
locate thefile
key of an entry and copy its value (the total path of the file) - Locate the
command
key of the corresponding entry and insert the value right after the path toclang++
and before the path to the.rsp
file - Repeat for each entry in
compile_commands.json
To verify that it is working try to run the command in a terminal. It should start compiling (don't expect it to finish without errors though). You might want to automate this procedure, especially if your project contains a lot of files. If requested, I can share the tool I quickly put together.
Also, if you are on Arch and experience long loading times when starting the editor follow the instructions on the Arch Wiki. It really makes a difference.
OS - Arch Linux
VIM - Vi IMproved 8.2
NVIM - 0.6.1
coc.nvim - 0.0.80
clangd - 12.0.1
Unreal - 4.27
OS - Windows MSYS
VIM - Vi IMproved 8.2
NVIM - 0.6.1
Unreal - 4.27
Rhighs: On Windows it was too slugghish and indexing took a ton of time more in big proejcts compared to what I've experienced on Arch Linux. At the end I surrendered to the evil of MS Visual Studio + VSVim extension.