diff options
author | Matthieu Coudron <mcoudron@hotmail.com> | 2022-04-29 12:05:37 +0200 |
---|---|---|
committer | Matthieu Coudron <mcoudron@hotmail.com> | 2022-05-11 10:42:19 +0200 |
commit | 08b6ad0ea504ff34e58638319ea717ef7fac09a4 (patch) | |
tree | 71435cf6be7460f8627f49498c393346e2086f52 /pkgs/applications/editors | |
parent | 6936329cf217bff9a5ef26cbacbbcd52e41bd6dd (diff) |
buildVimPlugin: check that neovim can require the module.
Add: ``` doInstallCheck = true; nvimRequireCheck = "toto"; ``` to your vimPluginCall.
Diffstat (limited to 'pkgs/applications/editors')
4 files changed, 37 insertions, 2 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..e0978db4527ea 100644 --- a/pkgs/applications/editors/vim/plugins/build-vim-plugin.nix +++ b/pkgs/applications/editors/vim/plugins/build-vim-plugin.nix @@ -3,6 +3,7 @@ , vim , vimCommandCheckHook , vimGenDocHook +, neovimRequireCheckHook }: rec { @@ -31,7 +32,7 @@ rec { forceShare= [ "man" "info" ]; nativeBuildInputs = attrs.nativeBuildInputs or [] - ++ [ vimCommandCheckHook ] + ++ [ vimCommandCheckHook neovimRequireCheckHook ] ++ lib.optional (stdenv.hostPlatform == stdenv.buildPlatform) vimGenDocHook; inherit unpackPhase configurePhase buildPhase addonInfo preInstall postInstall; 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..590f530954d11 --- /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 -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 e294ea0b5a2b1..078989406a80a 100644 --- a/pkgs/applications/editors/vim/plugins/overrides.nix +++ b/pkgs/applications/editors/vim/plugins/overrides.nix @@ -321,6 +321,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..69633d24c3c3c 100644 --- a/pkgs/applications/editors/vim/plugins/vim-utils.nix +++ b/pkgs/applications/editors/vim/plugins/vim-utils.nix @@ -531,8 +531,18 @@ 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; |