🧑🏽💻 Why use Neovim with Unreal Engine? #
In this post, we see how you can work in Unreal Engine with Neovim for game development. Unreal Engine lets you define game logic using Blueprints (a codeless Visual Scripting UI) or C++. We focus on C++ in this post. The solution has been tested on macOS, but might also run just fine on Linux, and possibly Windows. Please let me know either way how you fared, if you tried those alternatives.
Officially, Unreal Engine does not support Neovim. That said, you might still prefer to opt for a lightweight text Neovim editor, like Neovide, which has a small memory footprint — useful when you have a resource-intensive game open, in the background in the Unreal Engine Editor. Neovide, written in Rust, is a no-nonsense, cross-platform Neovim GUI. Of course, it supports code code completions, quick fixes and other features you will expect from a modern editor.
If you are just looking to use Vim movements to make your editing more efficient, there is another alternative. You might consider using CLion or VS Code as your editor, and adding a Vim plugin that will let you use those Vim movements. This post targets readers who are already familiar with Neovim, LSP and setting up plugins, though there are links included for guides, which might be helpful for anyone not yet comfortable configuring Neovim.
🎮 Editing Unreal Engine C++ Code in Neovim #
We jump straight in to configuring Neovim here. If you want to know how to set up Unreal Engine on macOS, or use VS Code as your editor, see the UE5 macOS post. However, if you appreciate the benefits of a lean editor like Neovide , let’s see how to configure Neovim to run with Unreal Engine.
On macOS, Unreal Engine uses the Clang compiler. Clang is highly configurable and fantastic for working with Neovim. You will need the LSP plugin with Clang set up in your Neovim installation to get code completion, linting, quick fixes and so on.
Unreal Engine does not officially support Neovim, but to generate project files required below, you can use Unreal Engine, as described in the UE5 macOS post. For a detailed guide on setting up Neovim generally, with LSP and more, see this excellent tutorial from Jake Wiesler .
For LSP with Plug you will add something like this to your Neovim init.vim
config file:
The last two plugins help provide autocompletion.
Then, add some Clang-specific config to your LSP config:
Apart from this config, you shouldn’t need any more setup, just to have Clang 11 or newer installed on your system, which you should already have from installing Xcode. You can see LSP Clang configuration options in the project GitHub repo , though.
Creating a Project compile_commands.json
#
To get the most out of Neovim, you will need one more config file: compile_commands.json
. This is a Clang requirement, which lets the compiler tooling provide completions and lints for
your Unreal project. You can generate it by running a command, from the Terminal:
Update the Unreal Engine path if you are using a different version or have it installed elsewhere.
If this has run successfully, you should see a message telling you where Unreal Engine output the JSON file to:
Copy this output file to the root folder of your project, and now you should have code completion etc..
Building your project from the Terminal #
To build your project, you will run command:
Again, update the command to match your Unreal Engine version and exact path. See other available
build commands by scanning through the [YourProjectName].code-workspace
file in the root directory of your project.
🗳 Poll #
🛁 Adding Linting Configuration #
To add linting to your Unreal project, using Clang tooling, just add a .clang-tidy
file to your project root directory. If you do not yet have one, as a starting point, choose:
- the .clang-tidy config used in the VS Code C/C++ Config Extension ; or
- an alternative .clang-tidy from a C++ Best Practices repo by Jason Turner.
🙌🏽 Unreal Engine with Neovim: Wrapping Up #
In this Unreal Engine with Neovim post, we saw how you can get going with game development in Unreal Engine and Neovim. More specifically, we saw:
- a resource for setting up Unreal Engine for C++ coding with macOS;
-
how to generate a Clang
compile_commands.json
file for your Unreal Engine project; and - how to configure Neovim with Unreal Engine code quick fixes, lints and more.
I hope you found this useful. Do let me know if you found this content useful and would like to see more similar content. Also reach out if there is anything I could improve to provide a better experience for you.
🙏🏽 Unreal Engine with Neovim: Feedback #
If you have found this post useful, see links below for further related content on this site. Let me know if there are any ways I can improve on it. I hope you will use the code or starter in your own projects. Be sure to share your work on X, giving me a mention, so I can see what you did. Finally, be sure to let me know ideas for other short videos you would like to see. Read on to find ways to get in touch, further below. If you have found this post useful, even though you can only afford even a tiny contribution, please consider supporting me through Buy me a Coffee.
Just dropped a new post on generating a compile_commands.json file for your Unreal project, opening up access to quick fixes, code completion and API documentation.
— Rodney (@askRodney) January 24, 2024
All thanks to the Clang LSP plugin for Neovim.
Hope you find the post useful!
https://t.co/1w2RtE2cqT
Finally, feel free to share the post on your social media accounts for all your followers who will find it useful. As well as leaving a comment below, you can get in touch via @askRodney on X (previously Twitter) and also, join the #rodney Element Matrix room. Also, see further ways to get in touch with Rodney Lab. I post regularly on Game Dev as well as Rust and C++ (among other topics). Also, subscribe to the newsletter to keep up-to-date with our latest projects.