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

vimPlugins followup
This commit is contained in:
Matthieu Coudron 2021-09-17 16:50:46 +02:00 committed by GitHub
commit 4ad9704bc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 15 deletions

View File

@ -87,10 +87,30 @@ rec {
nvim_with_plug = neovim.override {
extraName = "-with-plug";
configure.plug.plugins = with pkgs.vimPlugins; [
vim-go
base16-vim
];
configure.customRC = ''
color base16-tomorrow-night
set background=dark
'';
};
run_nvim_with_plug = runTest nvim_with_plug ''
export HOME=$TMPDIR
${nvim_with_plug}/bin/nvim -i NONE -c 'color base16-tomorrow-night' +quit!
'';
# check that the vim-doc hook correctly generates the tag
# we know for a fact packer has a doc folder
checkForTags = vimPlugins.packer-nvim.overrideAttrs(oldAttrs: {
doInstallCheck = true;
installCheckPhase = ''
[ -f $out/doc/tags ]
'';
});
# nixpkgs should detect that no wrapping is necessary
nvimShouldntWrap = wrapNeovim2 "-should-not-wrap" nvimAutoDisableWrap;

View File

@ -6,7 +6,7 @@
rec {
addRtp = path: attrs: derivation:
derivation // { rtp = "${derivation}/${path}"; } // {
derivation // { rtp = "${derivation}"; } // {
overrideAttrs = f: buildVimPlugin (attrs // f attrs);
};
@ -26,6 +26,9 @@ rec {
addRtp "${rtpPath}/${path}" attrs (stdenv.mkDerivation (attrs // {
name = namePrefix + name;
# dont move the doc folder since vim expects it
forceShare= [ "man" "info" ];
nativeBuildInputs = attrs.nativeBuildInputs or [] ++ [ vimGenDocHook ];
inherit unpackPhase configurePhase buildPhase addonInfo preInstall postInstall;

View File

@ -37,6 +37,9 @@
, xkb-switch
, ycmd
# test dependencies
, neovim-unwrapped
# command-t dependencies
, rake
, ruby
@ -392,6 +395,12 @@ self: super: {
substituteInPlace $out/bin/minimap_generator.sh \
--replace "code-minimap" "${code-minimap}/bin/code-minimap"
'';
doCheck = true;
checkPhase = ''
${neovim-unwrapped}/bin/nvim -n -u NONE -i NONE -V1 --cmd "set rtp+=$out" --cmd "runtime! plugin/*.vim" -c "MinimapToggle" +quit!
'';
});
ncm2 = super.ncm2.overrideAttrs (old: {

View File

@ -5,7 +5,7 @@ echo "Sourcing vim-gen-doc-hook"
vimPluginGenTags() {
echo "Executing vimPluginGenTags"
target="$out/@rtpPath@/$pname"
target="$out/@rtpPath@"
mkdir -p $out/@rtpPath@
# build help tags
@ -16,7 +16,7 @@ vimPluginGenTags() {
exit 1
fi
else
echo "No docs available"
echo "No docs available for $target"
fi
if [ -n "$addonInfo" ]; then

View File

@ -187,8 +187,9 @@ let
rtpPath = ".";
nativeImpl = packages:
(let
# Generates a packpath folder as expected by vim
packDir = packages:
let
# dir is "start" or "opt"
linkLuaPlugin = plugin: packageName: dir: ''
mkdir -p $out/pack/${packageName}/${dir}/${plugin.pname}/lua
@ -205,7 +206,7 @@ let
then linkLuaPlugin pluginPath
else linkVimlPlugin pluginPath;
packageLinks = (packageName: {start ? [], opt ? []}:
packageLinks = packageName: {start ? [], opt ? []}:
let
# `nativeImpl` expects packages to be derivations, not strings (as
# opposed to older implementations that have to maintain backwards
@ -230,21 +231,20 @@ let
++ [
"mkdir -p $out/pack/${packageName}/start/__python3_dependencies"
"ln -s ${python3Env}/${python3Env.sitePackages} $out/pack/${packageName}/start/__python3_dependencies/python3"
]
);
packDir = (packages:
];
in
stdenv.mkDerivation {
name = "vim-pack-dir";
src = ./.;
installPhase = lib.concatStringsSep "\n" (lib.flatten (lib.mapAttrsToList packageLinks packages));
preferLocalBuild = true;
}
);
in
};
nativeImpl = packages:
''
set packpath^=${packDir packages}
set runtimepath^=${packDir packages}
'');
'';
/* Generates a vimrc string
@ -295,7 +295,7 @@ let
plugImpl =
(''
source ${vimPlugins.vim-plug.rtp}/plug.vim
call plug#begin('/dev/null')
silent! call plug#begin('/dev/null')
'' + (lib.concatMapStringsSep "\n" (pkg: "Plug '${pkg.rtp}'") plug.plugins) + ''