Creating a standalone executable for Neovim based on iTerm2
I use Neovim on OS X as my code editor.
I am quite happy to use it in the terminal, but I find it helpful to have a separate application that I can run in full screen and can switch to independently of iTerm2.
I tried some of the standalone Neovim applications, but was generally unhappy with them for one reason or another. So I decided to make a standalone version that runs inside iTerm2.
Running Neovim this way is great because it leverages the power and stability of iTerm2. iTerm2 has great support for customization of appearance and keyboard rebinding.
Here’s how to build a standalone version of Neovim that’s based on iTerm2.
I am not a developer of Mac applications, so the following is based on a bit of trial and error and fiddling around with XCode. This is the method I’ve used to build a standalone version of Neovim several times across several versions of Neovim and XCode.
These steps have been tested with XCode 11.2.
-
Clone iTerm2 master from GitHub https://github.com/gnachman/iTerm2
-
Open XCode and choose “Open another project…”. Select the directory where you cloned iTerm2.
- Change Bundle ID to (something like) co.uk.cloudship.neovim
- Under Signing & Capabilities change to “Sign to run locally”
- In the right-hand pane change Name to Neovim
A window will appear helping you rename all instances of iTerm2 to Neovim.
- Update the icons.
Find Supporting Files > Images > Media.xcassets (you can use the filter at the bottom of the file list window)
Grab the Neovim icon from here: https://raw.githubusercontent.com/neovim/neovim.github.io/master/logos/neovim-mark.png
I used Iconfly to generate AppIcon.appiconset (select generate without scaling).
Drag the AppIcon.appiconset folder to Xterm.
Remove the old icon set and rename the new one to the old name.
- I tried building at this point but it failed due to a reference somewhere to iTerm2.pch.
In XCode, select the project and go to Build Settings.
Under targets select NeovimSharedArc.
In the filter, enter GCC_PREFIX.
Under the setting Prefix Header, update the value to sources/Neovim.pch
.
-
Replace all references to
iTerm2SharedARC-Swift.h
withNeovimSharedARC-Swift.h
-
Build the application by hitting ⌘-R.
-
Copy Neovim to applications.
Under Products right click on Neovim.app and select “Show in Finder”.
Move Neovim.app to applications.
- All done!
You should be able to run Neovim.app now.
What I did after this was create a separate profile for Neovim in iTerm2 that
runs the following at startup: nvim && exit
. This option is under Profiles >
General as “send text at start”) in the iTerm2 (and now Neovim) preferences.