Skip to content

Instantly share code, notes, and snippets.

@equalsraf
Last active May 14, 2021 11:42
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save equalsraf/efa3337718cd973de5713c3a84b10fc7 to your computer and use it in GitHub Desktop.
Save equalsraf/efa3337718cd973de5713c3a84b10fc7 to your computer and use it in GitHub Desktop.
Neovim in Cygwin

TLDR; no, libuv doesn't work in Cygwin just yet, see at the bottom.

Requirements

I tested using the master branch (9d3449852bd35c9283948186d0259c1bf73b8579 or later)

I installed the following in the cygwin setup

  • gcc-c++ make cmake pkg-config libtool
  • unzip
  • lua (5.2), lua-devel, lua-bit, lua-lpeg

Build third party deps

in the Neovim folder

mkdir .deps-cyg
cd .deps-cyg
 cmake ../third-party/ -DUSE_BUNDLED_JEMALLOC=OFF -DUSE_BUNDLED_BUSTED=OFF -DUSE_BUNDLED_LUAJIT=OFF -DUSE_BUNDLED_LUV=OFF -DUSE_BUNDLED_LUAROCKS=OFF
make

One of the current issues is that mpack fails to build in third-party, and it also fails to build in lua 5.2 which is used in cygwin (there is a PR for that) lets build it by hand then

Here is a quick recipe for lua.5.2, that last command will prompt you for permissions

git clone https://github.com/y-stm/libmpack.git
cd libmpack
gcc -O2 -fPIC -I/usr/include/lua5.2 -c binding/lua/lmpack.c -o lmpack.o
gcc -shared -o mpack.dll lmpack.o -llua-5.2
cygstart --action=runas cp mpack.dll /usr/lib/lua/5.2/

You can check if mpack was installed with the command

lua -e "require('mpack')"

Build Neovim

Go back to the Neovim folder and apply the following patch (it disables the stack-protect for cygwin, since it was failing for missing symbols)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 317d2a1..f5f2356 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -230,7 +230,7 @@ if(HAS_WVLA_FLAG)
   add_definitions(-Wvla)
 endif()

-if(UNIX)
+if(UNIX AND NOT CYGWIN)
   # -fstack-protector breaks non Unix builds even in Mingw-w64
   check_c_compiler_flag(-fstack-protector-strong HAS_FSTACK_PROTECTOR_STRONG_FLAG)
   check_c_compiler_flag(-fstack-protector HAS_FSTACK_PROTECTOR_FLAG)

Build instructions are fairly standard

mkdir build-cyg
cd build-cyg
cmake .. -DDEPS_PREFIX=../.deps-cyg/usr
make

Right now it fails when linking, the issue seems libuv related.

Issues

In order of importance

@sohnryang
Copy link

sohnryang commented Jul 31, 2017

TLDR; no, libuv doesn't work in Cygwin just yet, see at the bottom.

Well, libuv does support cygwin. It compiles well, but it fails some unit tests.
See libuv/libuv#1423.

@cascent
Copy link

cascent commented Sep 25, 2017

I've got Neovim running on Cygwin. https://github.com/cascent/neovim-cygport

@cascent
Copy link

cascent commented Nov 12, 2017

now I am using neovim 0.2.1 on cygwin: https://github.com/cascent/neovim-cygwin
I've renamed my repo from "neovim-cygport" to "neovim-cygwin" in the hopes that it's seen by more people, because it's a shame this gist is the top google result when searching for how to run neovim on cygwin.

@mallochine
Copy link

@cascent you have a windows binary of neovim you can share? So that I don't have to build the stuff from scratch. Figuring out cygport looks hairy...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment