neovim: pass packpath via the wrapper
Adding "packages" to the neovim distribution triggers the wrapping of the derivation. This is because it tries to "set packpath/rtp" in the init.vim. If we set these arguments via --cmd instead we can avoid to create an init.vim, which can be useful if we want to wrap an init.lua later on (in home-manager for instance, we dont want to generate viml code). Also removes the support for "configure" in makeNeovimConfig and configure.plug / configure.vam packages in the compatibility layer 'legacyWrapper'.
This commit is contained in:
parent
0fb2e47b7f
commit
cda1f8ae46
4 changed files with 50 additions and 43 deletions
|
@ -1,7 +1 @@
|
|||
" configuration generated by NIX
|
||||
set nocompatible
|
||||
|
||||
set packpath^=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-vim-pack-dir
|
||||
set runtimepath^=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-vim-pack-dir
|
||||
|
||||
:help ale
|
||||
|
|
|
@ -86,9 +86,11 @@ rec {
|
|||
|
||||
nvim_with_plug = neovim.override {
|
||||
extraName = "-with-plug";
|
||||
configure.plug.plugins = with pkgs.vimPlugins; [
|
||||
(base16-vim.overrideAttrs(old: { pname = old.pname + "-unique-for-tests-please-dont-use"; }))
|
||||
];
|
||||
configure.packages.plugins = with pkgs.vimPlugins; {
|
||||
start = [
|
||||
(base16-vim.overrideAttrs(old: { pname = old.pname + "-unique-for-tests-please-dont-use"; }))
|
||||
];
|
||||
};
|
||||
configure.customRC = ''
|
||||
color base16-tomorrow-night
|
||||
set background=dark
|
||||
|
@ -123,7 +125,7 @@ rec {
|
|||
});
|
||||
|
||||
force-nowrap = runTest nvimDontWrap ''
|
||||
! grep "-u" ${nvimDontWrap}/bin/nvim
|
||||
! grep -F -- ' -u' ${nvimDontWrap}/bin/nvim
|
||||
'';
|
||||
|
||||
nvim_via_override-test = runTest nvim_via_override ''
|
||||
|
|
|
@ -11,15 +11,16 @@
|
|||
, wrapNeovimUnstable
|
||||
}:
|
||||
let
|
||||
# returns everything needed for the caller to wrap its own neovim:
|
||||
# - the generated content of the future init.vim
|
||||
# - the arguments to wrap neovim with
|
||||
# The caller is responsible for writing the init.vim and adding it to the wrapped
|
||||
# arguments (["-u" writeText "init.vim" GENERATEDRC)]).
|
||||
# This makes it possible to write the config anywhere: on a per-project basis
|
||||
# .nvimrc or in $XDG_CONFIG_HOME/nvim/init.vim to avoid sideeffects.
|
||||
# Indeed, note that wrapping with `-u init.vim` has sideeffects like .nvimrc wont be loaded
|
||||
# anymore, $MYVIMRC wont be set etc
|
||||
/* returns everything needed for the caller to wrap its own neovim:
|
||||
- the generated content of the future init.vim
|
||||
- the arguments to wrap neovim with
|
||||
The caller is responsible for writing the init.vim and adding it to the wrapped
|
||||
arguments (["-u" writeText "init.vim" GENERATEDRC)]).
|
||||
This makes it possible to write the config anywhere: on a per-project basis
|
||||
.nvimrc or in $XDG_CONFIG_HOME/nvim/init.vim to avoid sideeffects.
|
||||
Indeed, note that wrapping with `-u init.vim` has sideeffects like .nvimrc wont be loaded
|
||||
anymore, $MYVIMRC wont be set etc
|
||||
*/
|
||||
makeNeovimConfig =
|
||||
{
|
||||
withPython2 ? false
|
||||
|
@ -36,10 +37,8 @@ let
|
|||
# expects a list of plugin configuration
|
||||
# expects { plugin=far-vim; config = "let g:far#source='rg'"; optional = false; }
|
||||
, plugins ? []
|
||||
# forwarded to configure.customRC
|
||||
# custom viml config appended after plugin-specific config
|
||||
, customRC ? ""
|
||||
# same values as in vimUtils.vimrcContent (deprecated)
|
||||
, configure ? { }
|
||||
|
||||
# for forward compability, when adding new environments, haskell etc.
|
||||
, ...
|
||||
|
@ -54,25 +53,20 @@ let
|
|||
};
|
||||
|
||||
# transform all plugins into an attrset
|
||||
pluginsNormalized = map (x: if x ? plugin then { optional = false; } // x else { plugin = x; optional = false;}) plugins;
|
||||
# { optional = bool; plugin = package; dest = filename; }
|
||||
pluginsNormalized = map (x: if x ? plugin then { dest = "init.vim"; optional = false; } // x else { plugin = x; optional = false;}) plugins;
|
||||
|
||||
|
||||
configurePatched = configure // {
|
||||
customRC = pluginRc + customRC + (configure.customRC or "");
|
||||
};
|
||||
|
||||
# A function to get the configuration string (if any) from an element of 'plugins'
|
||||
pluginConfig = p:
|
||||
if (p.config or "") != "" then ''
|
||||
" ${p.plugin.pname or p.plugin.name} {{{
|
||||
${p.config}
|
||||
" }}}
|
||||
'' else "";
|
||||
pluginRC = lib.concatMapStrings (p: p.config or "") pluginsNormalized;
|
||||
|
||||
pluginRc = lib.concatMapStrings pluginConfig pluginsNormalized;
|
||||
|
||||
requiredPlugins = vimUtils.requiredPlugins configurePatched;
|
||||
pluginsPartitioned = lib.partition (x: x.optional == true) pluginsNormalized;
|
||||
requiredPlugins = vimUtils.requiredPluginsForPackage myVimPackage;
|
||||
getDeps = attrname: map (plugin: plugin.${attrname} or (_: [ ]));
|
||||
myVimPackage = {
|
||||
start = map (x: x.plugin) pluginsPartitioned.wrong;
|
||||
opt = map (x: x.plugin) pluginsPartitioned.right;
|
||||
};
|
||||
|
||||
pluginPython3Packages = getDeps "python3Dependencies" requiredPlugins;
|
||||
python3Env = python3Packages.python.withPackages (ps:
|
||||
|
@ -102,8 +96,16 @@ let
|
|||
let
|
||||
binPath = lib.makeBinPath (lib.optionals withRuby [ rubyEnv ] ++ lib.optionals withNodeJs [ nodejs ]);
|
||||
|
||||
hostProviderViml = lib.mapAttrsToList genProviderSettings hostprog_check_table;
|
||||
|
||||
# as expected by packdir
|
||||
packDirArgs.myNeovimPackages = myVimPackage;
|
||||
|
||||
# vim accepts a limited number of commands so we join them all
|
||||
flags = [ "--cmd" (lib.intersperse "|" (lib.mapAttrsToList genProviderSettings hostprog_check_table)) ];
|
||||
flags = [
|
||||
"--cmd" (lib.intersperse "|" hostProviderViml)
|
||||
"--cmd" "set packpath^=${vimUtils.packDir packDirArgs}"
|
||||
];
|
||||
in
|
||||
[
|
||||
"--inherit-argv0" "--add-flags" (lib.escapeShellArgs flags)
|
||||
|
@ -116,9 +118,9 @@ let
|
|||
"--prefix" "LUA_CPATH" ";" (neovim-unwrapped.lua.pkgs.lib.genLuaCPathAbsStr luaEnv)
|
||||
];
|
||||
|
||||
|
||||
manifestRc = vimUtils.vimrcContent (configurePatched // { customRC = ""; }) ;
|
||||
neovimRcContent = vimUtils.vimrcContent configurePatched;
|
||||
manifestRc = vimUtils.vimrcContent ({ customRC = ""; }) ;
|
||||
# we call vimrcContent without 'packages' to avoid the init.vim generation
|
||||
neovimRcContent = vimUtils.vimrcContent ({ beforePlugins = ""; customRC = pluginRC + customRC; packages = null; });
|
||||
in
|
||||
assert withPython2 -> throw "Python2 support has been removed from neovim, please remove withPython2 and extraPython2Packages.";
|
||||
|
||||
|
@ -140,7 +142,7 @@ let
|
|||
"let g:loaded_${prog}_provider=0"
|
||||
;
|
||||
|
||||
# to keep backwards compatibility
|
||||
# to keep backwards compatibility for people using neovim.override
|
||||
legacyWrapper = neovim: {
|
||||
extraMakeWrapperArgs ? ""
|
||||
, withPython ? false
|
||||
|
@ -163,12 +165,21 @@ let
|
|||
(_: lib.warn "passing a list as extraPythonPackages to the neovim wrapper is deprecated, pass a function as to python.withPackages instead" funOrList)
|
||||
else funOrList);
|
||||
|
||||
# we convert from the old configure.format to
|
||||
plugins = if builtins.hasAttr "plug" configure then
|
||||
throw "The neovim legacy wrapper doesn't support configure.plug anymore, please setup your plugins via 'configure.packages' instead"
|
||||
else
|
||||
lib.flatten (lib.mapAttrsToList genPlugin (configure.packages or {}));
|
||||
genPlugin = packageName: {start ? [], opt?[]}:
|
||||
start ++ opt;
|
||||
|
||||
res = makeNeovimConfig {
|
||||
inherit withPython3;
|
||||
extraPython3Packages = compatFun extraPython3Packages;
|
||||
inherit extraLuaPackages;
|
||||
inherit withNodeJs withRuby viAlias vimAlias;
|
||||
inherit configure;
|
||||
customRC = configure.customRC or "";
|
||||
inherit plugins;
|
||||
inherit extraName;
|
||||
};
|
||||
in
|
||||
|
|
|
@ -236,7 +236,7 @@ let
|
|||
*/
|
||||
vimrcContent = {
|
||||
packages ? null,
|
||||
vam ? null,
|
||||
vam ? null, # deprecated
|
||||
pathogen ? null, # deprecated
|
||||
plug ? null,
|
||||
beforePlugins ? ''
|
||||
|
|
Loading…
Reference in a new issue