about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/editors/neovim
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/applications/editors/neovim')
-rw-r--r--nixpkgs/pkgs/applications/editors/neovim/default.nix128
-rw-r--r--nixpkgs/pkgs/applications/editors/neovim/neovim-remote.nix26
-rw-r--r--nixpkgs/pkgs/applications/editors/neovim/qt.nix78
-rw-r--r--nixpkgs/pkgs/applications/editors/neovim/ruby_provider/Gemfile3
-rw-r--r--nixpkgs/pkgs/applications/editors/neovim/ruby_provider/Gemfile.lock17
-rw-r--r--nixpkgs/pkgs/applications/editors/neovim/ruby_provider/gemset.nix27
-rw-r--r--nixpkgs/pkgs/applications/editors/neovim/system_rplugin_manifest.patch29
-rw-r--r--nixpkgs/pkgs/applications/editors/neovim/wrapper.nix133
8 files changed, 441 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/applications/editors/neovim/default.nix b/nixpkgs/pkgs/applications/editors/neovim/default.nix
new file mode 100644
index 000000000000..56f846f0c5f9
--- /dev/null
+++ b/nixpkgs/pkgs/applications/editors/neovim/default.nix
@@ -0,0 +1,128 @@
+{ stdenv, fetchFromGitHub, cmake, gettext, msgpack, libtermkey, libiconv
+, libuv, lua, ncurses, pkgconfig
+, unibilium, xsel, gperf
+, libvterm-neovim
+, withJemalloc ? true, jemalloc
+, glibcLocales ? null, procps ? null
+
+# now defaults to false because some tests can be flaky (clipboard etc)
+, doCheck ? false
+}:
+
+with stdenv.lib;
+
+let
+  neovimLuaEnv = lua.withPackages(ps:
+    (with ps; [ mpack lpeg luabitop ]
+    ++ optionals doCheck [
+        nvim-client luv coxpcall busted luafilesystem penlight inspect
+      ]
+    ));
+in
+  stdenv.mkDerivation rec {
+    name = "neovim-unwrapped-${version}";
+    version = "0.3.7";
+
+    src = fetchFromGitHub {
+      owner = "neovim";
+      repo = "neovim";
+      rev = "v${version}";
+      sha256 = "1j6w5jvq5v7kf7diad91qs1acr427nidnk9s24yyrz0hwdd1c2lh";
+    };
+
+    patches = [
+      # introduce a system-wide rplugin.vim in addition to the user one
+      # necessary so that nix can handle `UpdateRemotePlugins` for the plugins
+      # it installs. See https://github.com/neovim/neovim/issues/9413.
+      ./system_rplugin_manifest.patch
+    ];
+
+    dontFixCmake = true;
+    enableParallelBuilding = true;
+
+    buildInputs = [
+      libtermkey
+      libuv
+      msgpack
+      ncurses
+      libvterm-neovim
+      unibilium
+      gperf
+      neovimLuaEnv
+    ] ++ optional withJemalloc jemalloc
+      ++ optional stdenv.isDarwin libiconv
+      ++ optionals doCheck [ glibcLocales procps ]
+    ;
+
+    inherit doCheck;
+
+    # to be exhaustive, one could run
+    # make oldtests too
+    checkPhase = ''
+      make functionaltest
+    '';
+
+    nativeBuildInputs = [
+      cmake
+      gettext
+      pkgconfig
+    ];
+
+
+    # nvim --version output retains compilation flags and references to build tools
+    postPatch = ''
+      substituteInPlace src/nvim/version.c --replace NVIM_VERSION_CFLAGS "";
+    '';
+    # check that the above patching actually works
+    disallowedReferences = [ stdenv.cc ];
+
+    cmakeFlags = [
+      "-DLUA_PRG=${neovimLuaEnv.interpreter}"
+      "-DGPERF_PRG=${gperf}/bin/gperf"
+    ]
+    ++ optional doCheck "-DBUSTED_PRG=${neovimLuaEnv}/bin/busted"
+    ++ optional (!lua.pkgs.isLuaJIT) "-DPREFER_LUA=ON"
+    ;
+
+    # triggers on buffer overflow bug while running tests
+    hardeningDisable = [ "fortify" ];
+
+    preConfigure = stdenv.lib.optionalString stdenv.isDarwin ''
+      export DYLD_LIBRARY_PATH=${jemalloc}/lib
+      substituteInPlace src/nvim/CMakeLists.txt --replace "    util" ""
+    '';
+
+    postInstall = stdenv.lib.optionalString stdenv.isLinux ''
+      sed -i -e "s|'xsel|'${xsel}/bin/xsel|g" $out/share/nvim/runtime/autoload/provider/clipboard.vim
+    '' + stdenv.lib.optionalString (withJemalloc && stdenv.isDarwin) ''
+      install_name_tool -change libjemalloc.1.dylib \
+                ${jemalloc}/lib/libjemalloc.1.dylib \
+                $out/bin/nvim
+    '';
+
+    # export PATH=$PWD/build/bin:${PATH}
+    shellHook=''
+      export VIMRUNTIME=$PWD/runtime
+    '';
+
+    meta = {
+      description = "Vim text editor fork focused on extensibility and agility";
+      longDescription = ''
+        Neovim is a project that seeks to aggressively refactor Vim in order to:
+        - Simplify maintenance and encourage contributions
+        - Split the work between multiple developers
+        - Enable the implementation of new/modern user interfaces without any
+          modifications to the core source
+        - Improve extensibility with a new plugin architecture
+      '';
+      homepage    = https://www.neovim.io;
+      # "Contributions committed before b17d96 by authors who did not sign the
+      # Contributor License Agreement (CLA) remain under the Vim license.
+      # Contributions committed after b17d96 are licensed under Apache 2.0 unless
+      # those contributions were copied from Vim (identified in the commit logs
+      # by the vim-patch token). See LICENSE for details."
+      license = with licenses; [ asl20 vim ];
+      maintainers = with maintainers; [ manveru garbas rvolosatovs ];
+      platforms   = platforms.unix;
+    };
+  }
diff --git a/nixpkgs/pkgs/applications/editors/neovim/neovim-remote.nix b/nixpkgs/pkgs/applications/editors/neovim/neovim-remote.nix
new file mode 100644
index 000000000000..52888c5f85d5
--- /dev/null
+++ b/nixpkgs/pkgs/applications/editors/neovim/neovim-remote.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchFromGitHub, pythonPackages }:
+
+with stdenv.lib;
+
+pythonPackages.buildPythonApplication rec {
+  pname = "neovim-remote";
+  version = "2.1.7";
+  disabled = !pythonPackages.isPy3k;
+
+  src = fetchFromGitHub {
+    owner = "mhinz";
+    repo = "neovim-remote";
+    rev = "v${version}";
+    sha256 = "014c8xvb7shy00vjx0b1k8zr7iknxskqab1aqvz9md3bn5rwkxm5";
+  };
+
+  propagatedBuildInputs = with pythonPackages; [ pynvim psutil ];
+
+  meta = {
+    description = "A tool that helps controlling nvim processes from a terminal";
+    homepage = https://github.com/mhinz/neovim-remote/;
+    license = licenses.mit;
+    maintainers = with maintainers; [ edanaher ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/editors/neovim/qt.nix b/nixpkgs/pkgs/applications/editors/neovim/qt.nix
new file mode 100644
index 000000000000..3004bf544c42
--- /dev/null
+++ b/nixpkgs/pkgs/applications/editors/neovim/qt.nix
@@ -0,0 +1,78 @@
+{ stdenv, fetchFromGitHub, cmake, doxygen, makeWrapper
+, msgpack, neovim, pythonPackages, qtbase }:
+
+let
+  unwrapped = stdenv.mkDerivation rec {
+    pname = "neovim-qt-unwrapped";
+    version = "0.2.11";
+
+    src = fetchFromGitHub {
+      owner  = "equalsraf";
+      repo   = "neovim-qt";
+      rev    = "v${version}";
+      sha256 = "0pc1adxc89p2rdvb6nxyqr9sjzqz9zw2dg7a4ardxsl3a8jga1wh";
+    };
+
+    cmakeFlags = [
+      "-DUSE_SYSTEM_MSGPACK=1"
+    ];
+
+    buildInputs = [
+      neovim.unwrapped # only used to generate help tags at build time
+      qtbase
+    ] ++ (with pythonPackages; [
+      jinja2 python msgpack
+    ]);
+
+    nativeBuildInputs = [ cmake doxygen makeWrapper ];
+
+    enableParallelBuilding = true;
+
+    preCheck = ''
+      # The GUI tests require a running X server, disable them
+      sed -i ../test/CMakeLists.txt \
+        -e '/^add_xtest_gui/d'
+    '';
+
+    doCheck = true;
+
+    meta = with stdenv.lib; {
+      description = "Neovim client library and GUI, in Qt5";
+      license     = licenses.isc;
+      maintainers = with maintainers; [ peterhoeg ];
+      inherit (neovim.meta) platforms;
+      inherit version;
+    };
+  };
+in
+  stdenv.mkDerivation {
+    pname = "neovim-qt";
+    version = unwrapped.version;
+    buildCommand = if stdenv.isDarwin then ''
+      mkdir -p $out/Applications
+      cp -r ${unwrapped}/bin/nvim-qt.app $out/Applications
+
+      chmod -R a+w "$out/Applications/nvim-qt.app/Contents/MacOS"
+      wrapProgram "$out/Applications/nvim-qt.app/Contents/MacOS/nvim-qt" \
+        --prefix PATH : "${neovim}/bin"
+    '' else ''
+      makeWrapper '${unwrapped}/bin/nvim-qt' "$out/bin/nvim-qt" \
+        --prefix PATH : "${neovim}/bin"
+
+      # link .desktop file
+      mkdir -p "$out/share"
+      ln -s '${unwrapped}/share/applications' "$out/share/applications"
+    '';
+
+    preferLocalBuild = true;
+
+    nativeBuildInputs = [
+      makeWrapper
+    ];
+
+    passthru = {
+      inherit unwrapped;
+    };
+
+    inherit (unwrapped) meta;
+  }
diff --git a/nixpkgs/pkgs/applications/editors/neovim/ruby_provider/Gemfile b/nixpkgs/pkgs/applications/editors/neovim/ruby_provider/Gemfile
new file mode 100644
index 000000000000..eebecf2906fb
--- /dev/null
+++ b/nixpkgs/pkgs/applications/editors/neovim/ruby_provider/Gemfile
@@ -0,0 +1,3 @@
+source 'https://rubygems.org'
+
+gem 'neovim'
diff --git a/nixpkgs/pkgs/applications/editors/neovim/ruby_provider/Gemfile.lock b/nixpkgs/pkgs/applications/editors/neovim/ruby_provider/Gemfile.lock
new file mode 100644
index 000000000000..6a3f581c4e81
--- /dev/null
+++ b/nixpkgs/pkgs/applications/editors/neovim/ruby_provider/Gemfile.lock
@@ -0,0 +1,17 @@
+GEM
+  remote: https://rubygems.org/
+  specs:
+    msgpack (1.2.6)
+    multi_json (1.13.1)
+    neovim (0.8.0)
+      msgpack (~> 1.1)
+      multi_json (~> 1.0)
+
+PLATFORMS
+  ruby
+
+DEPENDENCIES
+  neovim
+
+BUNDLED WITH
+   1.17.2
diff --git a/nixpkgs/pkgs/applications/editors/neovim/ruby_provider/gemset.nix b/nixpkgs/pkgs/applications/editors/neovim/ruby_provider/gemset.nix
new file mode 100644
index 000000000000..28a53cc590f6
--- /dev/null
+++ b/nixpkgs/pkgs/applications/editors/neovim/ruby_provider/gemset.nix
@@ -0,0 +1,27 @@
+{
+  msgpack = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "0031gd2mjyba6jb7m97sqa149zjkr0vzn2s2gpb3m9nb67gqkm13";
+      type = "gem";
+    };
+    version = "1.2.6";
+  };
+  multi_json = {
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "1rl0qy4inf1mp8mybfk56dfga0mvx97zwpmq5xmiwl5r770171nv";
+      type = "gem";
+    };
+    version = "1.13.1";
+  };
+  neovim = {
+    dependencies = ["msgpack" "multi_json"];
+    source = {
+      remotes = ["https://rubygems.org"];
+      sha256 = "07scrdfk7pyn5jgx5m2yajdqpbdv42833vbw568qqag6xp99j3yk";
+      type = "gem";
+    };
+    version = "0.8.0";
+  };
+}
diff --git a/nixpkgs/pkgs/applications/editors/neovim/system_rplugin_manifest.patch b/nixpkgs/pkgs/applications/editors/neovim/system_rplugin_manifest.patch
new file mode 100644
index 000000000000..f634d3ec056a
--- /dev/null
+++ b/nixpkgs/pkgs/applications/editors/neovim/system_rplugin_manifest.patch
@@ -0,0 +1,29 @@
+diff --git a/runtime/autoload/remote/host.vim b/runtime/autoload/remote/host.vim
+index 6266b312b..965fabf1e 100644
+--- a/runtime/autoload/remote/host.vim
++++ b/runtime/autoload/remote/host.vim
+@@ -71,7 +71,8 @@ function! remote#host#RegisterPlugin(host, path, specs) abort
+ 
+   for plugin in plugins
+     if plugin.path == a:path
+-      throw 'Plugin "'.a:path.'" is already registered'
++      " plugin already registered
++      return
+     endif
+   endfor
+ 
+diff --git a/runtime/plugin/rplugin.vim b/runtime/plugin/rplugin.vim
+index 122d8d47f..83fbf8b57 100644
+--- a/runtime/plugin/rplugin.vim
++++ b/runtime/plugin/rplugin.vim
+@@ -54,6 +54,10 @@ function! s:GetManifest() abort
+ endfunction
+ 
+ function! s:LoadRemotePlugins() abort
++  if exists('$NVIM_SYSTEM_RPLUGIN_MANIFEST')
++    let g:system_remote_plugins = fnamemodify($NVIM_SYSTEM_RPLUGIN_MANIFEST, ':p')
++    execute 'source' fnameescape(g:system_remote_plugins)
++  endif
+   let g:loaded_remote_plugins = s:GetManifest()
+   if filereadable(g:loaded_remote_plugins)
+     execute 'source' fnameescape(g:loaded_remote_plugins)
diff --git a/nixpkgs/pkgs/applications/editors/neovim/wrapper.nix b/nixpkgs/pkgs/applications/editors/neovim/wrapper.nix
new file mode 100644
index 000000000000..aa1e2a6b5bd7
--- /dev/null
+++ b/nixpkgs/pkgs/applications/editors/neovim/wrapper.nix
@@ -0,0 +1,133 @@
+{ stdenv, lib, makeWrapper
+, vimUtils
+, bundlerEnv, ruby
+, nodejs
+, nodePackages
+, pythonPackages
+, python3Packages
+}:
+with stdenv.lib;
+
+neovim:
+
+let
+  wrapper = {
+      extraMakeWrapperArgs ? ""
+    , withPython ? true,  extraPythonPackages ? (_: []) /* the function you would have passed to python.withPackages */
+    , withPython3 ? true,  extraPython3Packages ? (_: []) /* the function you would have passed to python.withPackages */
+    , withNodeJs? false
+    , withRuby ? true
+    , vimAlias ? false
+    , viAlias ? false
+    , configure ? {}
+  }:
+  let
+
+  rubyEnv = bundlerEnv {
+    name = "neovim-ruby-env";
+    gemdir = ./ruby_provider;
+    postBuild = ''
+      ln -sf ${ruby}/bin/* $out/bin
+    '';
+  };
+
+  /* for compatibility with passing extraPythonPackages as a list; added 2018-07-11 */
+  compatFun = funOrList: (if builtins.isList funOrList then
+    (_: lib.warn "passing a list as extraPythonPackages to the neovim wrapper is deprecated, pass a function as to python.withPackages instead" funOrList)
+    else funOrList);
+  extraPythonPackagesFun = compatFun extraPythonPackages;
+  extraPython3PackagesFun = compatFun extraPython3Packages;
+
+  requiredPlugins = vimUtils.requiredPlugins configure;
+  getDeps = attrname: map (plugin: plugin.${attrname} or (_:[]));
+
+  pluginPythonPackages = getDeps "pythonDependencies" requiredPlugins;
+  pythonEnv = pythonPackages.python.withPackages(ps:
+        [ ps.pynvim ]
+        ++ (extraPythonPackagesFun ps)
+        ++ (concatMap (f: f ps) pluginPythonPackages));
+
+  pluginPython3Packages = getDeps "python3Dependencies" requiredPlugins;
+  python3Env = python3Packages.python.withPackages (ps:
+        [ ps.pynvim ]
+        ++ (extraPython3PackagesFun ps)
+        ++ (concatMap (f: f ps) pluginPython3Packages));
+
+  binPath = makeBinPath (optionals withRuby [rubyEnv] ++ optionals withNodeJs [nodejs]);
+
+  in
+  stdenv.mkDerivation {
+      name = "neovim-${stdenv.lib.getVersion neovim}";
+      buildCommand = let bin="${neovim}/bin/nvim"; in ''
+        if [ ! -x "${bin}" ]
+        then
+            echo "cannot find executable file \`${bin}'"
+            exit 1
+        fi
+
+        makeWrapper "$(readlink -v --canonicalize-existing "${bin}")" \
+          "$out/bin/nvim" --add-flags " \
+        --cmd \"${if withNodeJs then "let g:node_host_prog='${nodePackages.neovim}/bin/neovim-node-host'" else "let g:loaded_node_provider=1"}\" \
+        --cmd \"${if withPython then "let g:python_host_prog='$out/bin/nvim-python'" else "let g:loaded_python_provider = 1"}\" \
+        --cmd \"${if withPython3 then "let g:python3_host_prog='$out/bin/nvim-python3'" else "let g:loaded_python3_provider = 1"}\" \
+        --cmd \"${if withRuby then "let g:ruby_host_prog='$out/bin/nvim-ruby'" else "let g:loaded_ruby_provider=1"}\" " \
+        --suffix PATH : ${binPath} \
+        ${optionalString withRuby '' --set GEM_HOME ${rubyEnv}/${rubyEnv.ruby.gemPath}'' }
+      ''
+      + optionalString (!stdenv.isDarwin) ''
+        # copy and patch the original neovim.desktop file
+        mkdir -p $out/share/applications
+        substitute ${neovim}/share/applications/nvim.desktop $out/share/applications/nvim.desktop \
+          --replace 'TryExec=nvim' "TryExec=$out/bin/nvim" \
+          --replace 'Name=Neovim' 'Name=WrappedNeovim'
+      ''
+      + optionalString withPython ''
+        makeWrapper ${pythonEnv}/bin/python $out/bin/nvim-python --unset PYTHONPATH
+      '' + optionalString withPython3 ''
+        makeWrapper ${python3Env}/bin/python3 $out/bin/nvim-python3 --unset PYTHONPATH
+      '' + optionalString withRuby ''
+        ln -s ${rubyEnv}/bin/neovim-ruby-host $out/bin/nvim-ruby
+      '' + optionalString vimAlias ''
+        ln -s $out/bin/nvim $out/bin/vim
+      '' + optionalString viAlias ''
+        ln -s $out/bin/nvim $out/bin/vi
+      '' + optionalString (configure != {}) ''
+        echo "Generating remote plugin manifest"
+        export NVIM_RPLUGIN_MANIFEST=$out/rplugin.vim
+        # Launch neovim with a vimrc file containing only the generated plugin
+        # code. Pass various flags to disable temp file generation
+        # (swap/viminfo) and redirect errors to stderr.
+        # Only display the log on error since it will contain a few normally
+        # irrelevant messages.
+        if ! $out/bin/nvim \
+          -u ${vimUtils.vimrcFile (configure // { customRC = ""; })} \
+          -i NONE -n \
+          -E -V1rplugins.log -s \
+          +UpdateRemotePlugins +quit! > outfile 2>&1; then
+          cat outfile
+          echo -e "\nGenerating rplugin.vim failed!"
+          exit 1
+        fi
+        unset NVIM_RPLUGIN_MANIFEST
+
+        # this relies on a patched neovim, see
+        # https://github.com/neovim/neovim/issues/9413
+        wrapProgram $out/bin/nvim \
+          --set NVIM_SYSTEM_RPLUGIN_MANIFEST $out/rplugin.vim \
+          --add-flags "-u ${vimUtils.vimrcFile configure}" ${extraMakeWrapperArgs}
+      '';
+
+    preferLocalBuild = true;
+
+    buildInputs = [makeWrapper];
+    passthru = { unwrapped = neovim; };
+
+    meta = neovim.meta // {
+      description = neovim.meta.description;
+      hydraPlatforms = [];
+      # prefer wrapper over the package
+      priority = (neovim.meta.priority or 0) - 1;
+    };
+  };
+in
+  lib.makeOverridable wrapper