buildVimPlugin: add vimCommandCheckHook

Modeled after pythonImportCheckHook, this checks a command can be run once the plugin is installed

authored by Matthieu Coudron and committed by Matthieu Coudron 9663a29a 2415f1e0

+47 -9
+2
pkgs/applications/editors/vim/plugins/build-vim-plugin.nix
··· 1 { lib, stdenv 2 , rtpPath 3 , vim 4 , vimGenDocHook 5 }: 6 ··· 30 forceShare= [ "man" "info" ]; 31 32 nativeBuildInputs = attrs.nativeBuildInputs or [] 33 ++ lib.optional (stdenv.hostPlatform == stdenv.buildPlatform) vimGenDocHook; 34 inherit unpackPhase configurePhase buildPhase addonInfo preInstall postInstall; 35
··· 1 { lib, stdenv 2 , rtpPath 3 , vim 4 + , vimCommandCheckHook 5 , vimGenDocHook 6 }: 7 ··· 31 forceShare= [ "man" "info" ]; 32 33 nativeBuildInputs = attrs.nativeBuildInputs or [] 34 + ++ [ vimCommandCheckHook ] 35 ++ lib.optional (stdenv.hostPlatform == stdenv.buildPlatform) vimGenDocHook; 36 inherit unpackPhase configurePhase buildPhase addonInfo preInstall postInstall; 37
+5 -2
pkgs/applications/editors/vim/plugins/default.nix
··· 3 4 let 5 6 - inherit (vimUtils.override {inherit vim;}) buildVimPluginFrom2Nix vimGenDocHook; 7 8 inherit (lib) extends; 9 ··· 12 toVimPlugin = drv: 13 drv.overrideAttrs(oldAttrs: { 14 15 - nativeBuildInputs = oldAttrs.nativeBuildInputs or [] ++ [ vimGenDocHook ]; 16 passthru = (oldAttrs.passthru or {}) // { 17 vimPlugin = true; 18 };
··· 3 4 let 5 6 + inherit (vimUtils.override {inherit vim;}) buildVimPluginFrom2Nix vimGenDocHook vimCommandCheckHook; 7 8 inherit (lib) extends; 9 ··· 12 toVimPlugin = drv: 13 drv.overrideAttrs(oldAttrs: { 14 15 + nativeBuildInputs = oldAttrs.nativeBuildInputs or [] ++ [ 16 + vimGenDocHook 17 + vimCommandCheckHook 18 + ]; 19 passthru = (oldAttrs.passthru or {}) // { 20 vimPlugin = true; 21 };
+2 -5
pkgs/applications/editors/vim/plugins/overrides.nix
··· 450 --replace "code-minimap" "${code-minimap}/bin/code-minimap" 451 ''; 452 453 - doCheck = true; 454 - checkPhase = '' 455 - ${neovim-unwrapped}/bin/nvim -n -u NONE -i NONE -V1 --cmd "set rtp+=$out" --cmd "runtime! plugin/*.vim" -c "MinimapToggle" +quit! 456 - ''; 457 - 458 }); 459 460 ncm2 = super.ncm2.overrideAttrs (old: {
··· 450 --replace "code-minimap" "${code-minimap}/bin/code-minimap" 451 ''; 452 453 + doInstallCheck = true; 454 + vimCommandCheck = "MinimapToggle"; 455 }); 456 457 ncm2 = super.ncm2.overrideAttrs (old: {
+25
pkgs/applications/editors/vim/plugins/vim-command-check-hook.sh
···
··· 1 + # Setup hook for checking whether a vim command exists 2 + echo "Sourcing vim-command-check-hook.sh" 3 + 4 + vimCommandCheckHook () { 5 + echo "Executing vimCommandCheckHook" 6 + 7 + if [ -n "$vimCommandCheck" ]; then 8 + echo "Check whether the following modules can be imported: $vimCommandCheck" 9 + 10 + # editorconfig-checker-disable 11 + export HOME="$TMPDIR" 12 + @vimBinary@ -es -n -u NONE -i NONE --clean -V1 --cmd "set rtp+=$out" \ 13 + --cmd "runtime! plugin/*.vim" <<-EOF 14 + if exists(":$vimCommandCheck") == 2 15 + cquit 0 16 + else 17 + cquit 1 18 + fi 19 + EOF 20 + fi 21 + } 22 + 23 + echo "Using vimCommandCheckHook" 24 + preDistPhases+=" vimCommandCheckHook" 25 +
+13 -2
pkgs/applications/editors/vim/plugins/vim-utils.nix
··· 521 }; 522 } ./vim-gen-doc-hook.sh) {}; 523 524 - inherit (import ./build-vim-plugin.nix { inherit lib stdenv rtpPath vim vimGenDocHook; }) 525 - buildVimPlugin buildVimPluginFrom2Nix; 526 527 # used to figure out which python dependencies etc. neovim needs 528 requiredPlugins = {
··· 521 }; 522 } ./vim-gen-doc-hook.sh) {}; 523 524 + vimCommandCheckHook = callPackage ({ neovim-unwrapped }: 525 + makeSetupHook { 526 + name = "vim-command-check-hook"; 527 + deps = [ neovim-unwrapped ]; 528 + substitutions = { 529 + vimBinary = "${neovim-unwrapped}/bin/nvim"; 530 + inherit rtpPath; 531 + }; 532 + } ./vim-command-check-hook.sh) {}; 533 + 534 + inherit (import ./build-vim-plugin.nix { 535 + inherit lib stdenv rtpPath vim vimGenDocHook vimCommandCheckHook; 536 + }) buildVimPlugin buildVimPluginFrom2Nix; 537 538 # used to figure out which python dependencies etc. neovim needs 539 requiredPlugins = {