- To build on Windows, see the [Building on Windows](#building-on-windows) section. _MSVC (Visual Studio) is recommended._
4.`sudo make install`
- Default install location is `/usr/local`
- On Debian/Ubuntu, instead of installing files directly with `sudo make install`, you can run `cd build && cpack -G DEB && sudo dpkg -i nvim-linux64.deb` to build DEB-package and install it. This should help ensuring the clean removal of installed files.
**Notes**:
- From the repository's root directory, running `make` will download and build all the needed dependencies and put the `nvim` executable in `build/bin`.
- Third-party dependencies (libuv, LuaJIT, etc.) are downloaded automatically to `.deps/`. See the [FAQ](FAQ#build-issues) if you have issues.
- After building, you can run the `nvim` executable without installing it by running `VIMRUNTIME=runtime ./build/bin/nvim`.
- If you plan to develop Neovim, install [Ninja](https://ninja-build.org/) for faster builds. It will automatically be used.
- Install [ccache](https://ccache.dev/) for faster rebuilds of Neovim. It's used by default. To disable it, use `CCACHE_DISABLE=true make`.
## Running tests
See [test/README.md](https://github.com/neovim/neovim/blob/master/test/README.md).
## Building
First make sure you installed the [build prerequisites](#build-prerequisites). Now that you have the dependencies, you can try other build targets explained below.
The _build type_ determines the level of used compiler optimizations and debug information:
-`Release`: Full compiler optimizations and no debug information. Expect the best performance from this build type. Often used by package maintainers.
-`Debug`: Full debug information; few optimizations. Use this for development to get meaningful output from debuggers like GDB or LLDB. This is the default if `CMAKE_BUILD_TYPE` is not specified.
-`RelWithDebInfo` ("Release With Debug Info"): Enables many optimizations and adds enough debug info so that when Neovim ever crashes, you can still get a backtrace.
So, for a release build, just use:
```
make CMAKE_BUILD_TYPE=Release
```
(Do not add a `-j` flag if `ninja` is installed! The build will be in parallel automatically.)
Afterwards, the `nvim` executable can be found in `build/bin`. To verify the build type after compilation, run:
```sh
./build/bin/nvim --version | grep ^Build
```
To install the executable to a certain location, use:
```
make CMAKE_INSTALL_PREFIX=$HOME/local/nvim install
```
CMake, our main build system, caches a lot of things in `build/CMakeCache.txt`. If you ever want to change `CMAKE_BUILD_TYPE` or `CMAKE_INSTALL_PREFIX`, run `rm -rf build` first. This is also required when rebuilding after a Git commit adds or removes files (including from `runtime`) — when in doubt, run `make distclean` (which is basically a shortcut for `rm -rf build .deps`).
By default (`USE_BUNDLED=1`), Neovim downloads and statically links its needed dependencies. In order to be able to use a debugger on these libraries, you might want to compile them with debug information as well:
<!-- THIS CAUSES SCREEN INTERFERENCE
```
make distclean
VERBOSE=1 DEBUG=1 make deps
```
-->
```
make distclean
make deps
```
## Building on Windows
### Windows / MSVC
**MSVC (Visual Studio) is the recommended way to build on Windows.** These steps were confirmed as of 2023.
1. Install [Visual Studio](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community) (2017 or later) with the _Desktop development with C++_ workload.
- On 32-bit Windows, you will need [this workaround](https://developercommunity.visualstudio.com/content/problem/212989/ninja-binary-format.html).
2. Open the Neovim project folder.
- Visual Studio should detect the cmake files and automatically start building...
3. Choose the `nvim.exe (bin\nvim.exe)` target and hit F5.
- If the build fails, it may be because Visual Studio started the build with `x64-{Debug,Release}` before you switched the configuration to `x86-Release`.
- Right-click _CMakeLists.txt → Delete Cache_.
- Right-click _CMakeLists.txt → Generate Cache_.
- If you see an "access violation" from `ntdll`, you can ignore it and continue.
4. If you set an error like `msgpackc.dll not found`, try the `nvim.exe (Install)` target. Then switch back to `nvim.exe (bin\nvim.exe)`.
### Windows / MSVC PowerShell
To build from the command line (i.e. invoke the `cmake` commands yourself),
1. Ensure you have the Visual Studio environment variables, using any of the following:
- Using the [Visual Studio Developer Command Prompt or Visual Studio Developer PowerShell](https://learn.microsoft.com/en-us/visualstudio/ide/reference/command-prompt-powershell?view=vs-2022)
- Invoking `Import-VisualStudioVars` in PowerShell from [this PowerShell module](https://github.com/Pscx/Pscx)
- Invoking `VsDevCmd.bat` in Command Prompt
```
VsDevCmd.bat -arch=x64
```
This is to make sure that `luarocks` finds the Visual Studio installation, and doesn't fall back to MinGW with errors like:
```
'mingw32-gcc' is not recognized as an internal or external command
```
2. From the "Developer PowerShell" or "Developer Command Prompt":
Install all dependencies the normal way, then build Neovim the normal way for a random CMake application (i.e. do not use the `Makefile` that automatically downloads and builds "bundled" dependencies).
The `cygport` repo contains Cygport files (e.g. `APKBUILD`, `PKGBUILD`) for all the dependencies not available in the Cygwin distribution, and describes any special commands or arguments needed to build. The Cygport definitions also try to describe the required dependencies for each one. Unless custom commands are provided, Cygport just calls `autogen`/`cmake`, `make`, `make install`, etc. in a clean and consistent way.
https://github.com/cascent/neovim-cygwin was built on Cygwin 2.9.0. Newer `libuv` should require slightly less patching. Some SSP stuff changed in Cygwin 2.10.0, so that might change things too when building Neovim.
### Windows / MSYS2 / MinGW
1. From the MSYS2 shell, install these packages:
```
pacman -S \
mingw-w64-x86_64-{gcc,cmake,make,ninja,diffutils}
```
2. From the Windows Command Prompt (`cmd.exe`), set up the `PATH` and build.
```cmd
set PATH=c:\msys64\mingw64\bin;c:\msys64\usr\bin;%PATH%
A normal build will create `.mo` files in `build/src/nvim/po`.
* If you see `msgfmt: command not found`, you need to install [`gettext`](http://en.wikipedia.org/wiki/Gettext). On most systems, the package is just called `gettext`.
### Localization check
To check the translations for `$LANG`, run `make -C build check-po-$LANG`. Examples:
```
cmake --build build --target check-po-de
cmake --build build --target check-po-pt_BR
```
-`check-po-$LANG` generates a detailed report in `./build/src/nvim/po/check-${LANG}.log`. (The report is generated by `nvim`, not by `msgfmt`.)
### Localization update
To update the `src/nvim/po/$LANG.po` file with the latest strings, run the following:
```
cmake --build build --target update-po-$LANG
```
- **Note**: Run `src/nvim/po/cleanup.vim` after updating.
## Compiler options
To see the chain of includes, use the `-H` option ([#918](https://github.com/neovim/neovim/issues/918)):
-`grep -v /usr/` is used to filter out system header files.
-`-save-temps` can be added as well to see expanded macros or commented assembly.
## Xcode and MSVC project files
CMake has a `-G` option for exporting to multiple [project file formats](http://www.cmake.org/cmake/help/v2.8.8/cmake.html#section_Generators), such as Xcode and Visual Studio.
For example, to use Xcode's static analysis GUI ([#167](https://github.com/neovim/neovim/issues/167#issuecomment-36136018)), you need to generate an Xcode project file from the Neovim Makefile (where `neovim/` is the top-level Neovim source code directory containing the main `Makefile`):
```
cmake -G Xcode neovim
```
The resulting project file can then be opened in Xcode.
## Custom Makefile
You can customize the build process locally by creating a `local.mk`, which is referenced at the top of the main `Makefile`. It's listed in `.gitignore`, so it can be used across branches. **A new target in `local.mk` overrides the default make-target.**
Here's a sample `local.mk` which adds a target to force a rebuild but *does not* override the default-target:
```make
all:
rebuild:
rm -rf build
make
```
## Third-party dependencies
Reference the [Debian package](https://packages.debian.org/sid/source/neovim) (or alternatively, the [Homebrew formula](https://github.com/Homebrew/homebrew-core/blob/master/Formula/neovim.rb)) for the precise list of dependencies/versions.
- Optional: Get the latest CMake from an [installer](https://github.com/Kitware/CMake/releases) or the [Python package](https://pypi.org/project/cmake/) (`pip install cmake`)
Starting from NixOS 18.03, the Neovim binary resides in the `neovim-unwrapped` Nix package (the `neovim` package being just a wrapper to setup runtime options like Ruby/Python support):
```sh
cd path/to/neovim/src
```
Drop into `nix-shell` to pull in the Neovim dependencies:
```
nix-shell '<nixpkgs>' -A neovim-unwrapped
```
Configure and build:
```sh
rm -rf build && cmakeConfigurePhase
buildPhase
```
Tests are not available by default, because of some unfixed failures. You can enable them via adding this package in your overlay:
If you get an error regarding a `sha256sum` mismatch, where the actual SHA-256 hash is `e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855`, then this is your issue (that's the `sha256sum` of an empty file).
### OpenBSD
```sh
doas pkg_add gmake cmake unzip curl gettext-tools
```
Build can sometimes fail when using the top level `Makefile`, apparently due to some third-party component (see [#2445-comment](https://github.com/neovim/neovim/issues/2445#issuecomment-108124236)). The following instructions use CMake:
```sh
mkdir .deps
cd .deps
cmake ../cmake.deps/
gmake
cd ..
mkdir build
cd build
cmake ..
gmake
```
### macOS
#### macOS / Homebrew
1. Install Xcode Command Line Tools: `xcode-select --install`
2. Install [Homebrew](http://brew.sh)
3. Install Neovim build dependencies:
```
brew install ninja cmake gettext curl
```
- **Note**: If you see Wget certificate errors (for older macOS versions less than 10.10):