Unreal Engine with Neovim: Config for Game Development
Tags: cpp, gamedev
Published: 2024-01-31 18:23:38

---
title: "Unreal Engine with Neovim: Config for Game Development"
published: "true"
description: "Unreal Engine Game Development using Neovim 🎮 how you can configure Neovim or the VS Code Vim plugin to work with Unreal Engine."
tags: "cplusplus, gamedev"
canonical_url: "https://rodneylab.com/unreal-engine-with-neovim/"
cover_image: "https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ytkh9ojbvgcg8bv6v4fk.png"

---
## 🧑🏽‍💻 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.

## ⚙️ Installing Xcode for Unreal Engine on macOS

Even though we do not use Xcode as the editor here, you will need Xcode installed on your system for compiling the under the hood.  Be sure to check the <a href="https://docs.unrealengine.com/5.3/en-US/ios-ipados-and-tvos-development-requirements-for-unreal-engine/">Unreal Engine Xcode requirements for your Unreal Engine version you are using</a>, and install the Xcode version listed as being supported.  As an example, I was able to compile code successfully using Xcode 15, but when I tried to re-open the project in Unreal Engine, I got a &ldquo;The following modules are missing or built with a different engine version&rdquo; error below (even after rebuilding).

![Unreal Engine with Neovim: Screenshot shows Unreal Engine Editor error dialogue advising "The following modules are missing or built with a different engine version".](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/udtt5u37lpjzd3p292l2.png)

However, by downgrading to Xcode 14.3, I got everything to run smoothly.  You can download the latest version of Xcode from the macOS App Store, using a shortcut already on your dock or Launchpad.  However, if you require an older version, you will need to <a aria-label="use the Apple Developer site to download X code"href="https://developer.apple.com/download/all/?q=Xcode">use the Apple Developer site to download Xcode</a>, logging in and completing any two-factor authorization requests.  I would recommend using Safari for the download; the file will be quite big and Safari supports resuming your download, in case the connection drops.

You can have Unreal Engine generate the necessary VS Code project configuration by setting VS Code as your editor, then opening VS Code from the menu in Unreal Engine.

## 🧱 Running Unreal Engine builds in VS Code 

With Xcode and Unreal Engine set up, let&rsquo;s have a look at how to run builds from VS Code.  To build your Unreal project using VS Code, install the <a aria-label="C/C++ V S Code extension from Microsoft"href="https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools">C/C++ VS Code extension from Microsoft</a>.

![Unreal Engine with Neovim: Scrren capture shows the C/C++ extension by Microsoft preview in the V S Code extensions view.  Current version is v.1.18.5 and there have been around 59 million downloads.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2pu99ay2m0kublos21m2.png)

Now we are ready to roll.  To run a development build, go to the **Terminal** menu and select **Run build Task&hellip;**.  From the options, choose  **[YourProjectName]Editor Mac Development Build**.  This will build your project, and you will be able to see any changes you made with the Unreal Engine Editor UI.  Run a quick rebuild, from within Unreal Engine Editor, by clicking the &ldquo;Recompile on the fly&rdquo; button in the status bar at the bottom right of the screen.

## 🎮 Editing Unreal Engine C++ Code in Neovim

The process above works fine, though, depending on your setup and project, you might appreciate the benefits of a <a href="https://neovide.dev/">lean editor like Neovide</a>.  So, let&rsquo;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 above, for VS Code.  For a detailed guide on setting up Neovim generally, with LSP and more, see this <a href="https://www.jakewiesler.com/blog/getting-started-with-vim">excellent tutorial from Jake Wiesler</a>.

For LSP with Plug you will add something like this to your Neovim `init.vim` config file:

```lua
Plug 'neovim/nvim-lspconfig'
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-nvim-lsp'
```

The last two plugins help provide autocompletion.

Then, add some Clang-specific config to your LSP config:

```lua
local on_attach = function(client, bufnr)
  -- TRUNCATED...
end
 
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
 
local servers = { 'clangd' }
for _, lsp in ipairs(servers) do
    nvim_lsp[lsp].setup  {
        capabilities = capabilities,
        on_attach = on_attach,
    }
end
```
Apart from this config, you shouldn&rsquo;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 <a aria-label="L S P clang configuration options in the project Git Hub repo" href="https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#clang">LSP Clang configuration options in the project GitHub repo</a>, 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:

```shell
"/Users/Shared/Epic\ Games/UE_5.3/Engine/Build/BatchFiles/Mac/Build.sh" \\
-mode=GenerateClangDatabase \\
-project=/Path/to/your/project/YourProjectName/YourProjectName.uproject \\
-game -engine [YourProjectName]Editor Mac Development  
```

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:

```shell
ClangDatabase written to /Users/Shared/Epic Games/UE_5.3/compile_commands.json
```

Copy this output file to the root folder of your project, and now you should have code completion etc..

![Unreal Engine with Neovim: Screen capture shows an Unreal Engine C++ actor file being edited in Neovim.  The user has pulled up the documentation for the Unreal Engine SetActorLocation A P I, shown in the top half of the editor window.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0r9x7gwn571van6otevo.png)

### Building your project from the Terminal

To build your project, you will run command:

```shell
/Users/Shared/Epic\ Games/UE_5.3/Engine/Build/BatchFiles/Mac/Build.sh \\
"/Path/to/your/project/YourProjectName/YourProjectName.uproject" \\
-game -engine [YourProjectName]Editor Target Development Mac    
```

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.

## 🛁 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:

- <a href="https://github.com/franneck94/Vscode-C-Cpp-Config/raw/master/templates/.clang-tidy">the .clang-tidy config used in the VS Code C/C++ Config Extension</a>; or
- an alternative <a href="https://github.com/cpp-best-practices/cmake_template/raw/main/.clang-tidy">.clang-tidy from a C++ Best Practices repo</a> 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:

- some pointers on **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 <a aria-label="Support Rodney Lab via Buy me a Coffee" href="https://rodneylab.com/giving/">consider supporting me through Buy me a Coffee</a>.

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 <a href="https://twitter.com/messages/compose?recipient_id=1323579817258831875">@askRodney</a> on X (previously Twitter) and also <a aria-label="Contact Rodney Lab via Telegram" href="https://t.me/askRodney">askRodney on Telegram</a>. Also, see <a aria-label="Get in touch with Rodney Lab" href="https://rodneylab.com/contact/">further ways to get in touch with Rodney Lab</a>. I post regularly on <a href="https://rodneylab.com/tags/deno/">Deno</a> as well as <a href="https://rodneylab.com/tags/seo/" aria-label="See posts on search engine optimisation">Search Engine Optimization</a> among other topics. Also, <a aria-label="Subscribe to the   Rodney Lab newsletter" href="https://newsletter.rodneylab.com/issue/latest-issue">subscribe to the newsletter to keep up-to-date</a> with our latest projects.