Merge pull request #137885 from teto/fix-vim-plug

vimPlugins followup

authored by

Matthieu Coudron and committed by
GitHub
4ad9704b d46295c6

+47 -15
+21 -1
pkgs/applications/editors/neovim/tests.nix
··· 87 nvim_with_plug = neovim.override { 88 extraName = "-with-plug"; 89 configure.plug.plugins = with pkgs.vimPlugins; [ 90 - vim-go 91 ]; 92 }; 93 94 # nixpkgs should detect that no wrapping is necessary 95 nvimShouldntWrap = wrapNeovim2 "-should-not-wrap" nvimAutoDisableWrap;
··· 87 nvim_with_plug = neovim.override { 88 extraName = "-with-plug"; 89 configure.plug.plugins = with pkgs.vimPlugins; [ 90 + base16-vim 91 ]; 92 + configure.customRC = '' 93 + color base16-tomorrow-night 94 + set background=dark 95 + ''; 96 }; 97 + 98 + run_nvim_with_plug = runTest nvim_with_plug '' 99 + export HOME=$TMPDIR 100 + ${nvim_with_plug}/bin/nvim -i NONE -c 'color base16-tomorrow-night' +quit! 101 + ''; 102 + 103 + 104 + # check that the vim-doc hook correctly generates the tag 105 + # we know for a fact packer has a doc folder 106 + checkForTags = vimPlugins.packer-nvim.overrideAttrs(oldAttrs: { 107 + doInstallCheck = true; 108 + installCheckPhase = '' 109 + [ -f $out/doc/tags ] 110 + ''; 111 + }); 112 + 113 114 # nixpkgs should detect that no wrapping is necessary 115 nvimShouldntWrap = wrapNeovim2 "-should-not-wrap" nvimAutoDisableWrap;
+4 -1
pkgs/misc/vim-plugins/build-vim-plugin.nix
··· 6 7 rec { 8 addRtp = path: attrs: derivation: 9 - derivation // { rtp = "${derivation}/${path}"; } // { 10 overrideAttrs = f: buildVimPlugin (attrs // f attrs); 11 }; 12 ··· 25 }: 26 addRtp "${rtpPath}/${path}" attrs (stdenv.mkDerivation (attrs // { 27 name = namePrefix + name; 28 29 nativeBuildInputs = attrs.nativeBuildInputs or [] ++ [ vimGenDocHook ]; 30 inherit unpackPhase configurePhase buildPhase addonInfo preInstall postInstall;
··· 6 7 rec { 8 addRtp = path: attrs: derivation: 9 + derivation // { rtp = "${derivation}"; } // { 10 overrideAttrs = f: buildVimPlugin (attrs // f attrs); 11 }; 12 ··· 25 }: 26 addRtp "${rtpPath}/${path}" attrs (stdenv.mkDerivation (attrs // { 27 name = namePrefix + name; 28 + 29 + # dont move the doc folder since vim expects it 30 + forceShare= [ "man" "info" ]; 31 32 nativeBuildInputs = attrs.nativeBuildInputs or [] ++ [ vimGenDocHook ]; 33 inherit unpackPhase configurePhase buildPhase addonInfo preInstall postInstall;
+9
pkgs/misc/vim-plugins/overrides.nix
··· 37 , xkb-switch 38 , ycmd 39 40 # command-t dependencies 41 , rake 42 , ruby ··· 392 substituteInPlace $out/bin/minimap_generator.sh \ 393 --replace "code-minimap" "${code-minimap}/bin/code-minimap" 394 ''; 395 }); 396 397 ncm2 = super.ncm2.overrideAttrs (old: {
··· 37 , xkb-switch 38 , ycmd 39 40 + # test dependencies 41 + , neovim-unwrapped 42 + 43 # command-t dependencies 44 , rake 45 , ruby ··· 395 substituteInPlace $out/bin/minimap_generator.sh \ 396 --replace "code-minimap" "${code-minimap}/bin/code-minimap" 397 ''; 398 + 399 + doCheck = true; 400 + checkPhase = '' 401 + ${neovim-unwrapped}/bin/nvim -n -u NONE -i NONE -V1 --cmd "set rtp+=$out" --cmd "runtime! plugin/*.vim" -c "MinimapToggle" +quit! 402 + ''; 403 + 404 }); 405 406 ncm2 = super.ncm2.overrideAttrs (old: {
+2 -2
pkgs/misc/vim-plugins/vim-gen-doc-hook.sh
··· 5 vimPluginGenTags() { 6 echo "Executing vimPluginGenTags" 7 8 - target="$out/@rtpPath@/$pname" 9 mkdir -p $out/@rtpPath@ 10 11 # build help tags ··· 16 exit 1 17 fi 18 else 19 - echo "No docs available" 20 fi 21 22 if [ -n "$addonInfo" ]; then
··· 5 vimPluginGenTags() { 6 echo "Executing vimPluginGenTags" 7 8 + target="$out/@rtpPath@" 9 mkdir -p $out/@rtpPath@ 10 11 # build help tags ··· 16 exit 1 17 fi 18 else 19 + echo "No docs available for $target" 20 fi 21 22 if [ -n "$addonInfo" ]; then
+11 -11
pkgs/misc/vim-plugins/vim-utils.nix
··· 187 188 rtpPath = "."; 189 190 - nativeImpl = packages: 191 - (let 192 # dir is "start" or "opt" 193 linkLuaPlugin = plugin: packageName: dir: '' 194 mkdir -p $out/pack/${packageName}/${dir}/${plugin.pname}/lua ··· 205 then linkLuaPlugin pluginPath 206 else linkVimlPlugin pluginPath; 207 208 - packageLinks = (packageName: {start ? [], opt ? []}: 209 let 210 # `nativeImpl` expects packages to be derivations, not strings (as 211 # opposed to older implementations that have to maintain backwards ··· 230 ++ [ 231 "mkdir -p $out/pack/${packageName}/start/__python3_dependencies" 232 "ln -s ${python3Env}/${python3Env.sitePackages} $out/pack/${packageName}/start/__python3_dependencies/python3" 233 - ] 234 - ); 235 - packDir = (packages: 236 stdenv.mkDerivation { 237 name = "vim-pack-dir"; 238 src = ./.; 239 installPhase = lib.concatStringsSep "\n" (lib.flatten (lib.mapAttrsToList packageLinks packages)); 240 preferLocalBuild = true; 241 - } 242 - ); 243 - in 244 '' 245 set packpath^=${packDir packages} 246 set runtimepath^=${packDir packages} 247 - ''); 248 249 /* Generates a vimrc string 250 ··· 295 plugImpl = 296 ('' 297 source ${vimPlugins.vim-plug.rtp}/plug.vim 298 - call plug#begin('/dev/null') 299 300 '' + (lib.concatMapStringsSep "\n" (pkg: "Plug '${pkg.rtp}'") plug.plugins) + '' 301
··· 187 188 rtpPath = "."; 189 190 + # Generates a packpath folder as expected by vim 191 + packDir = packages: 192 + let 193 # dir is "start" or "opt" 194 linkLuaPlugin = plugin: packageName: dir: '' 195 mkdir -p $out/pack/${packageName}/${dir}/${plugin.pname}/lua ··· 206 then linkLuaPlugin pluginPath 207 else linkVimlPlugin pluginPath; 208 209 + packageLinks = packageName: {start ? [], opt ? []}: 210 let 211 # `nativeImpl` expects packages to be derivations, not strings (as 212 # opposed to older implementations that have to maintain backwards ··· 231 ++ [ 232 "mkdir -p $out/pack/${packageName}/start/__python3_dependencies" 233 "ln -s ${python3Env}/${python3Env.sitePackages} $out/pack/${packageName}/start/__python3_dependencies/python3" 234 + ]; 235 + in 236 stdenv.mkDerivation { 237 name = "vim-pack-dir"; 238 src = ./.; 239 installPhase = lib.concatStringsSep "\n" (lib.flatten (lib.mapAttrsToList packageLinks packages)); 240 preferLocalBuild = true; 241 + }; 242 + 243 + nativeImpl = packages: 244 '' 245 set packpath^=${packDir packages} 246 set runtimepath^=${packDir packages} 247 + ''; 248 249 /* Generates a vimrc string 250 ··· 295 plugImpl = 296 ('' 297 source ${vimPlugins.vim-plug.rtp}/plug.vim 298 + silent! call plug#begin('/dev/null') 299 300 '' + (lib.concatMapStringsSep "\n" (pkg: "Plug '${pkg.rtp}'") plug.plugins) + '' 301