Unverified Commit a07d4ce6 authored by Matthieu Coudron's avatar Matthieu Coudron Committed by GitHub
Browse files

neovim: add extraLuaPackages to wrapNeovimUnstable (#499571)

parents 40206fb6 7906e299
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ For instance, `sqlite-lua` needs `g:sqlite_clib_path` to be set to work. Nixpkgs
- `wrapRc`: Nix, not being able to write in your `$HOME`, loads the
  generated Neovim configuration via the `$VIMINIT` environment variable, i.e. : `export VIMINIT='lua dofile("/nix/store/…-init.lua")'`. This has side effects like preventing Neovim from sourcing your `init.lua` in `$XDG_CONFIG_HOME/nvim` (see bullet 7 of [`:help startup`](https://neovim.io/doc/user/starting.html#startup) in Neovim). Disable it if you want to generate your own wrapper. You can still reuse the generated vimscript init code via `neovim.passthru.initRc`.
- `plugins`: A list of plugins to add to the wrapper.
- `extraLuaPackages`: A function passed on to `lua.withPackages`
- `withPython3`, `withNodeJs`, `withRuby` control when to enable neovim
  providers (see `:h provider`).

@@ -90,6 +91,7 @@ wrapNeovimUnstable neovim-unwrapped {
    (nvim-treesitter.withPlugins (p: [ p.nix p.python ]))
    hex-nvim
  ];
  extraLuaPackages = lp: [ lp.mpack ];
  withPython3 = true;
  withNodeJs = false;
  withRuby = false;
+4 −4
Original line number Diff line number Diff line
@@ -348,12 +348,12 @@ pkgs.lib.recurseIntoAttrs rec {
    configure.packages.foo.start = with vimPlugins; [ deoplete-nvim ];
  };

  nvimWithLuaPackages = wrapNeovim2 "-with-lua-packages" (makeNeovimConfig {
  nvimWithLuaPackages = wrapNeovim2 "-with-lua-packages" {
    extraLuaPackages = ps: [ ps.mpack ];
    customRC = ''
      lua require("mpack")
    luaRcContent = ''
      require("mpack")
    '';
  });
  };

  nvim_with_lua_packages = runTest nvimWithLuaPackages ''
    ${nvimWithLuaPackages}/bin/nvim -V3log.txt -i NONE --noplugin +quitall! -e
+17 −0
Original line number Diff line number Diff line
@@ -69,6 +69,8 @@ let
      # { plugin=far-vim; config = "let g:far#source='rg'"; optional = false; }
      # ]
      plugins ? [ ],
      # the function you would have passed to lua.withPackages
      extraLuaPackages ? (_: [ ]),
      ...
    }@attrs:
    assert
@@ -105,8 +107,23 @@ let
        packpathDirs.myNeovimPackages = vimPackageInfo.vimPackage;
        finalPackdir = neovimUtils.packDir packpathDirs;

        luaPathLuaRc =
          let
            luaEnv = lua.withPackages extraLuaPackages;

            # getLuaPath / getLuaCPath are not interpreter dependant at the moment and might thus cause
            # errors between luajit/Puc lua
            generatedLuaPath = lua.pkgs.getLuaPath luaEnv;
            generatedLuaCPath = lua.pkgs.getLuaCPath luaEnv;
          in
          ''
            package.path = "${generatedLuaPath}".. ";" .. package.path
            package.cpath = "${generatedLuaCPath}".. ";" .. package.cpath
          '';

        rcContent = lib.concatStringsSep "\n" (
          [
            luaPathLuaRc
            providerLuaRc
          ]
          ++ lib.optional (luaRcContent != "") luaRcContent