Unreal Engine support for Neovim
Requirements
Installation
Install with packer:
use {'zadirion/Unreal.nvim',
requires =
{
{"tpope/vim-dispatch"}
}
}
After installing with packer, open one of your Unreal project's source files, and run UnrealGenWithEngine
. This will go through all the engine source files and will generate a compatible clang compile-command for each, so that the lsp can properly parse them.
It will take a long time to go through all of them, but you only need to run this command once, for your engine.
After running it for the first time, it will open a configuration file in a new buffer. In this buffer set the value of the "EngineDir"
key to the path to Unreal Engine on your system. For example,
// UnrealNvim.json
{
"version": "0.0.2",
"EngineDir": "C:\\Program Files\\Epic Games\\UE_5.4\\"
"Targets": [
// ...
]
}
After doing that and saving the file, run :UnrealGenWithEngine
again.
From here onwards, you can use :UnrealGen
to generate the compile commands for just your project files. Feel free to do so every time you feel like the lsp is not picking up your symbols, such as when you added new source code files to your project or if you updated to latest changelist/commig in your version control.
:UnrealGen
will always ask you which target to generate compile_commands.json for. Just input the number corresponding to the desired configuration, and it will generate the json right next to the uproject
This should cause your LSP to start recognizing the Unreal types, including the ones from .generated.h files.
Commands
:UnrealGenWithEngine
generates the compile_commands.json and the compiler rsp files for the engine source code, so your LSP can properly parse the source code:UnrealGen
generates the compile_commands.json and the compiler rps files for your project, so your LSP can properly parse the source code:UnrealBuild
builds the project with unreal:UnrealRun
runs the project. It does not build it even if the source is out of date:UnrealCD
sets the current directory to the root folder of the unreal project (the one with the .uproject in it). I personally use this so Telescope only searches in the project directory, making it faster, especially for live_grepKnown Limitations
:AbortDispatch
and it will only work for the actual unreal build step, it won't work for the RSP generation build stepTroubleshooting
vim.g.unrealnvim_debug = true
clangd's LSP log can be found here: %localappdata%/nvim-data\lsp.log If you are unsure whether clangd 'sees' some of your code, looking at this log helps