Skip to content

Commit

Permalink
fix manifest generation
Browse files Browse the repository at this point in the history
  • Loading branch information
teto committed Oct 27, 2020
1 parent a61b30b commit 11781ab
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 28 deletions.
35 changes: 12 additions & 23 deletions pkgs/applications/editors/neovim/utils.nix
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ let
++ (extraPython3Packages ps)
++ (lib.concatMap (f: f ps) pluginPython3Packages));

binPath = lib.makeBinPath (lib.optionals withRuby [ rubyEnv ] ++ lib.optionals withNodeJs [ nodejs ]);

# Mapping a boolean argument to a key that tells us whether to add or not to
# add to nvim's 'embedded rc' this:
Expand All @@ -79,17 +78,13 @@ let
# We start with the executable itself NOTE we call this variable "initial"
# because if configure != {} we need to call makeWrapper twice, in order to
# avoid double wrapping, see comment near finalMakeWrapperArgs
initialMakeWrapperArgs =
makeWrapperArgs =
let
flags = lib.concatLists (lib.mapAttrsToList
(
binPath = lib.makeBinPath (lib.optionals withRuby [ rubyEnv ] ++ lib.optionals withNodeJs [ nodejs ]);

flags = lib.concatLists (lib.mapAttrsToList (
prog: withProg: [
"--cmd"
(if withProg then
"let g:${prog}_host_prog='${placeholder "out"}/bin/nvim-${prog}'"
else
"let g:loaded_${prog}_provider=1"
)
"--cmd" (genProviderSettings prog withProg)
]
)
hostprog_check_table);
Expand All @@ -101,31 +96,25 @@ let
] ++ lib.optionals (binPath != "") [
"--suffix" "PATH" ":" binPath
];
# If configure != {}, we can't generate the rplugin.vim file with e.g
# NVIM_SYSTEM_RPLUGIN_MANIFEST *and* NVIM_RPLUGIN_MANIFEST env vars set in
# the wrapper. That's why only when configure != {} (tested both here and
# when postBuild is evaluated), we call makeWrapper once to generate a
# wrapper with most arguments we need, excluding those that cause problems to
# generate rplugin.vim, but still required for the final wrapper.
finalMakeWrapperArgs = initialMakeWrapperArgs
# this relies on a patched neovim, see
# https://github.com/neovim/neovim/issues/9413
++ lib.optionals (configure != { }) [
"--set" "NVIM_SYSTEM_RPLUGIN_MANIFEST" "${placeholder "out"}/rplugin.vim"
];

manifestRc = vimUtils.vimrcContent (configure // { customRC = ""; });
neovimRcContent = vimUtils.vimrcContent configure;
in
{
wrapperArgs = finalMakeWrapperArgs;
wrapperArgs = makeWrapperArgs;
inherit neovimRcContent;
inherit manifestRc;
inherit rubyEnv;
inherit python2Env;
inherit python3Env;
};

genProviderSettings = prog: withProg:
if withProg then
"let g:${prog}_host_prog='${placeholder "out"}/bin/nvim-${prog}'"
else
"let g:loaded_${prog}_provider=1"
;

# to keep backwards compatibility
legacyWrapper = neovim: {
Expand Down
22 changes: 17 additions & 5 deletions pkgs/applications/editors/neovim/wrapper.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@ let
}:
let

# If configure != {}, we can't generate the rplugin.vim file with e.g
# NVIM_SYSTEM_RPLUGIN_MANIFEST *and* NVIM_RPLUGIN_MANIFEST env vars set in
# the wrapper. That's why only when configure != {} (tested both here and
# when postBuild is evaluated), we call makeWrapper once to generate a
# wrapper with most arguments we need, excluding those that cause problems to
# generate rplugin.vim, but still required for the final wrapper.
finalMakeWrapperArgs =
[ "${neovim}/bin/nvim" "${placeholder "out"}/bin/nvim" ] ++ wrapperArgs
;
[ "${neovim}/bin/nvim" "${placeholder "out"}/bin/nvim" ] ++ wrapperArgs ++
[ "--set" "NVIM_SYSTEM_RPLUGIN_MANIFEST" "${placeholder "out"}/rplugin.vim" ];
in
symlinkJoin {
name = "neovim-${stdenv.lib.getVersion neovim}";
Expand Down Expand Up @@ -58,9 +64,14 @@ let
+ optionalString viAlias ''
ln -s $out/bin/nvim $out/bin/vi
''
+ optionalString (manifestRc != null) ''
+ optionalString (manifestRc != null) (let
manifestWrapperArgs =
[ "${neovim}/bin/nvim" "${placeholder "out"}/bin/nvim-wrapper" ] ++ wrapperArgs;
in ''
echo "Generating remote plugin manifest"
export NVIM_RPLUGIN_MANIFEST=$out/rplugin.vim
makeWrapper ${lib.escapeShellArgs manifestWrapperArgs}
# Some plugins assume that the home directory is accessible for
# initializing caches, temporary files, etc. Even if the plugin isn't
# actively used, it may throw an error as soon as Neovim is launched
Expand All @@ -76,7 +87,7 @@ let
# (swap/viminfo) and redirect errors to stderr.
# Only display the log on error since it will contain a few normally
# irrelevant messages.
if ! $out/bin/nvim \
if ! $out/bin/nvim-wrapper \
-u ${writeText "manifest.vim" manifestRc} \
-i NONE -n \
-E -V1rplugins.log -s \
Expand All @@ -85,7 +96,8 @@ let
echo -e "\nGenerating rplugin.vim failed!"
exit 1
fi
''
rm "${placeholder "out"}/bin/nvim-wrapper"
'')
+ ''
rm $out/bin/nvim
makeWrapper ${lib.escapeShellArgs finalMakeWrapperArgs}
Expand Down

0 comments on commit 11781ab

Please sign in to comment.