about summary refs log tree commit diff
path: root/pkgs/applications/editors
diff options
context:
space:
mode:
authorMatthieu Coudron <teto@users.noreply.github.com>2022-05-13 23:24:57 +0200
committerGitHub <noreply@github.com>2022-05-13 23:24:57 +0200
commit05a3e5c21fb363cdc21b1c7debf6d1bdf9368ce4 (patch)
tree94dab4c87fce017b595410cf80693012336f3a4c /pkgs/applications/editors
parent7daec9cdd73b45b31a1012df321b9122de5ae42f (diff)
parentda8a322e7314ec27f24b50304bf5b0fe1f0c9897 (diff)
Merge pull request #171064 from teto/neovim-require-check-hook
buildVimPlugin: check that neovim can require the module.
Diffstat (limited to 'pkgs/applications/editors')
-rw-r--r--pkgs/applications/editors/vim/plugins/build-vim-plugin.nix13
-rw-r--r--pkgs/applications/editors/vim/plugins/neovim-require-check-hook.sh21
-rw-r--r--pkgs/applications/editors/vim/plugins/overrides.nix3
-rw-r--r--pkgs/applications/editors/vim/plugins/vim-utils.nix16
4 files changed, 44 insertions, 9 deletions
diff --git a/pkgs/applications/editors/vim/plugins/build-vim-plugin.nix b/pkgs/applications/editors/vim/plugins/build-vim-plugin.nix
index 187c068c0f093..4773cfb9e43e4 100644
--- a/pkgs/applications/editors/vim/plugins/build-vim-plugin.nix
+++ b/pkgs/applications/editors/vim/plugins/build-vim-plugin.nix
@@ -3,14 +3,10 @@
 , vim
 , vimCommandCheckHook
 , vimGenDocHook
+, neovimRequireCheckHook
 }:
 
 rec {
-  addRtp = path: attrs: derivation:
-    derivation // { rtp = "${derivation}"; } // {
-      overrideAttrs = f: buildVimPlugin (attrs // f attrs);
-    };
-
   buildVimPlugin = attrs@{
     name ? "${attrs.pname}-${attrs.version}",
     namePrefix ? "vimplugin-",
@@ -24,7 +20,7 @@ rec {
     addonInfo ? null,
     ...
   }:
-    addRtp "${rtpPath}/${path}" attrs (stdenv.mkDerivation (attrs // {
+    let drv = stdenv.mkDerivation (attrs // {
       name = namePrefix + name;
 
       # dont move the doc folder since vim expects it
@@ -44,7 +40,10 @@ rec {
 
         runHook postInstall
       '';
-    }));
+    });
+    in  drv.overrideAttrs(oa: {
+      rtp = "${drv}";
+    });
 
   buildVimPluginFrom2Nix = attrs: buildVimPlugin ({
     # vim plugins may override this
diff --git a/pkgs/applications/editors/vim/plugins/neovim-require-check-hook.sh b/pkgs/applications/editors/vim/plugins/neovim-require-check-hook.sh
new file mode 100644
index 0000000000000..5b454e0ff01b9
--- /dev/null
+++ b/pkgs/applications/editors/vim/plugins/neovim-require-check-hook.sh
@@ -0,0 +1,21 @@
+# Setup hook for checking whether Python imports succeed
+echo "Sourcing neovim-require-check-hook.sh"
+
+neovimRequireCheckHook () {
+    echo "Executing neovimRequireCheckHook"
+
+    if [ -n "$nvimRequireCheck" ]; then
+        echo "Check whether the following module can be imported: $nvimRequireCheck"
+
+		# editorconfig-checker-disable
+        export HOME="$TMPDIR"
+        @nvimBinary@ -es --headless -n -u NONE -i NONE --clean -V1 \
+            --cmd "set rtp+=$out" \
+            --cmd "lua require('$nvimRequireCheck')"
+    fi
+}
+
+echo "Using neovimRequireCheckHook"
+preDistPhases+=" neovimRequireCheckHook"
+
+
diff --git a/pkgs/applications/editors/vim/plugins/overrides.nix b/pkgs/applications/editors/vim/plugins/overrides.nix
index 3273d841c6579..04e28b5fc20f0 100644
--- a/pkgs/applications/editors/vim/plugins/overrides.nix
+++ b/pkgs/applications/editors/vim/plugins/overrides.nix
@@ -327,6 +327,9 @@ self: super: {
       sed -Ei lua/plenary/curl.lua \
           -e 's@(command\s*=\s*")curl(")@\1${curl}/bin/curl\2@'
     '';
+
+    doInstallCheck = true;
+    nvimRequireCheck = "plenary";
   });
 
   gruvbox-nvim = super.gruvbox-nvim.overrideAttrs (old: {
diff --git a/pkgs/applications/editors/vim/plugins/vim-utils.nix b/pkgs/applications/editors/vim/plugins/vim-utils.nix
index e685e398fc2b0..9511e4da19520 100644
--- a/pkgs/applications/editors/vim/plugins/vim-utils.nix
+++ b/pkgs/applications/editors/vim/plugins/vim-utils.nix
@@ -531,14 +531,26 @@ rec {
       };
     } ./vim-command-check-hook.sh) {};
 
+  neovimRequireCheckHook = callPackage ({ neovim-unwrapped }:
+    makeSetupHook {
+      name = "neovim-require-check-hook";
+      deps = [ neovim-unwrapped ];
+      substitutions = {
+        nvimBinary = "${neovim-unwrapped}/bin/nvim";
+        inherit rtpPath;
+      };
+    } ./neovim-require-check-hook.sh) {};
+
   inherit (import ./build-vim-plugin.nix {
-    inherit lib stdenv rtpPath vim vimGenDocHook vimCommandCheckHook;
+    inherit lib stdenv rtpPath vim vimGenDocHook vimCommandCheckHook neovimRequireCheckHook;
   }) buildVimPlugin buildVimPluginFrom2Nix;
 
 
   # TODO placeholder to ease working on automatic plugin detection
   # this should be a luarocks "flat" install with appropriate vim hooks
-  buildNeovimPluginFrom2Nix = buildVimPluginFrom2Nix;
+  buildNeovimPluginFrom2Nix = attrs: let drv = (buildVimPluginFrom2Nix attrs); in drv.overrideAttrs(oa: {
+    nativeBuildInputs = oa.nativeBuildInputs ++ [ neovimRequireCheckHook ];
+  });
 
   # used to figure out which python dependencies etc. neovim needs
   requiredPlugins = {