mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 03:23:29 +03:00
neovim: add 'autowrapRuntimeDeps' to append (#358587)
plugin runtime dependencies. A recurrent question is how to make LSP work on nix, with users wanting to install masons etc. I think it makes sense for neovim to install neovim plugins in a way that they work out of the box. That's one of the strengths of nix and a shortcoming of the neovim infrastructure. We suffix the PATH instead of prepend such that project versions of the software takes precedence. It's opt-in for now to but worth revisiting later for the previous reasons.
This commit is contained in:
parent
d18fae80ef
commit
c16f43f97c
3 changed files with 36 additions and 8 deletions
|
@ -170,12 +170,24 @@ in
|
||||||
'';
|
'';
|
||||||
|
|
||||||
nvim_with_autoconfigure = pkgs.neovim.overrideAttrs(oa: {
|
nvim_with_autoconfigure = pkgs.neovim.overrideAttrs(oa: {
|
||||||
plugins = [ vimPlugins.unicode-vim ];
|
plugins = [
|
||||||
|
vimPlugins.unicode-vim
|
||||||
|
vimPlugins.fzf-hoogle-vim
|
||||||
|
];
|
||||||
autoconfigure = true;
|
autoconfigure = true;
|
||||||
# legacy wrapper sets it to false
|
# legacy wrapper sets it to false
|
||||||
wrapRc = true;
|
wrapRc = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
nvim_with_runtimeDeps = pkgs.neovim.overrideAttrs({
|
||||||
|
plugins = [
|
||||||
|
pkgs.vimPlugins.hex-nvim
|
||||||
|
];
|
||||||
|
autowrapRuntimeDeps = true;
|
||||||
|
# legacy wrapper sets it to false
|
||||||
|
wrapRc = true;
|
||||||
|
});
|
||||||
|
|
||||||
nvim_with_ftplugin = let
|
nvim_with_ftplugin = let
|
||||||
# this plugin checks that it's ftplugin/vim.tex is loaded before $VIMRUNTIME/ftplugin/vim.tex
|
# this plugin checks that it's ftplugin/vim.tex is loaded before $VIMRUNTIME/ftplugin/vim.tex
|
||||||
# $VIMRUNTIME/ftplugin/vim.tex sources $VIMRUNTIME/ftplugin/initex.vim which sets b:did_ftplugin
|
# $VIMRUNTIME/ftplugin/vim.tex sources $VIMRUNTIME/ftplugin/initex.vim which sets b:did_ftplugin
|
||||||
|
@ -334,7 +346,6 @@ in
|
||||||
${nvim_with_opt_plugin}/bin/nvim -i NONE +quit! -e
|
${nvim_with_opt_plugin}/bin/nvim -i NONE +quit! -e
|
||||||
'';
|
'';
|
||||||
|
|
||||||
inherit nvim-with-luasnip;
|
|
||||||
|
|
||||||
autoconfigure = runTest nvim_with_autoconfigure ''
|
autoconfigure = runTest nvim_with_autoconfigure ''
|
||||||
assertFileContains \
|
assertFileContains \
|
||||||
|
@ -342,11 +353,18 @@ in
|
||||||
'${vimPlugins.unicode-vim.passthru.initLua}'
|
'${vimPlugins.unicode-vim.passthru.initLua}'
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
autowrap_runtime_deps = runTest nvim_with_runtimeDeps ''
|
||||||
|
assertFileContains \
|
||||||
|
"${nvim_with_runtimeDeps}/bin/nvim" \
|
||||||
|
'${pkgs.xxd}/bin'
|
||||||
|
'';
|
||||||
|
|
||||||
|
inherit nvim-with-luasnip;
|
||||||
# check that bringing in one plugin with lua deps makes those deps visible from wrapper
|
# check that bringing in one plugin with lua deps makes those deps visible from wrapper
|
||||||
# for instance luasnip has a dependency on jsregexp
|
# for instance luasnip has a dependency on jsregexp
|
||||||
can_require_transitive_deps =
|
can_require_transitive_deps =
|
||||||
runTest nvim-with-luasnip ''
|
runTest nvim-with-luasnip ''
|
||||||
cat ${nvim-with-luasnip}/bin/nvim
|
cat ${nvim-with-luasnip}/nvim
|
||||||
${nvim-with-luasnip}/bin/nvim -i NONE --cmd "lua require'jsregexp'" -e +quitall!
|
${nvim-with-luasnip}/bin/nvim -i NONE --cmd "lua require'jsregexp'" -e +quitall!
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,10 @@ let
|
||||||
# to work with nix.
|
# to work with nix.
|
||||||
# if true, the wrapper automatically appends those snippets when necessary
|
# if true, the wrapper automatically appends those snippets when necessary
|
||||||
, autoconfigure ? false
|
, autoconfigure ? false
|
||||||
|
|
||||||
|
# append to PATH runtime deps of plugins
|
||||||
|
, autowrapRuntimeDeps ? false
|
||||||
|
|
||||||
# should contain all args but the binary. Can be either a string or list
|
# should contain all args but the binary. Can be either a string or list
|
||||||
, wrapperArgs ? []
|
, wrapperArgs ? []
|
||||||
, withPython2 ? false
|
, withPython2 ? false
|
||||||
|
@ -120,7 +124,15 @@ let
|
||||||
wrapperArgsStr = if lib.isString wrapperArgs then wrapperArgs else lib.escapeShellArgs wrapperArgs;
|
wrapperArgsStr = if lib.isString wrapperArgs then wrapperArgs else lib.escapeShellArgs wrapperArgs;
|
||||||
|
|
||||||
generatedWrapperArgs = let
|
generatedWrapperArgs = let
|
||||||
binPath = lib.makeBinPath (lib.optional finalAttrs.withRuby rubyEnv ++ lib.optional finalAttrs.withNodeJs nodejs);
|
op = acc: normalizedPlugin: acc ++ normalizedPlugin.plugin.runtimeDeps or [];
|
||||||
|
|
||||||
|
runtimeDeps = lib.foldl' op [] pluginsNormalized;
|
||||||
|
|
||||||
|
binPath = lib.makeBinPath (
|
||||||
|
lib.optional finalAttrs.withRuby rubyEnv
|
||||||
|
++ lib.optional finalAttrs.withNodeJs nodejs
|
||||||
|
++ lib.optionals finalAttrs.autowrapRuntimeDeps runtimeDeps
|
||||||
|
);
|
||||||
in
|
in
|
||||||
|
|
||||||
# vim accepts a limited number of commands so we join them all
|
# vim accepts a limited number of commands so we join them all
|
||||||
|
@ -167,7 +179,7 @@ let
|
||||||
__structuredAttrs = true;
|
__structuredAttrs = true;
|
||||||
dontUnpack = true;
|
dontUnpack = true;
|
||||||
inherit viAlias vimAlias withNodeJs withPython3 withPerl withRuby;
|
inherit viAlias vimAlias withNodeJs withPython3 withPerl withRuby;
|
||||||
inherit autoconfigure wrapRc providerLuaRc packpathDirs;
|
inherit autoconfigure autowrapRuntimeDeps wrapRc providerLuaRc packpathDirs;
|
||||||
inherit python3Env rubyEnv;
|
inherit python3Env rubyEnv;
|
||||||
inherit wrapperArgs generatedWrapperArgs;
|
inherit wrapperArgs generatedWrapperArgs;
|
||||||
luaRcContent = rcContent;
|
luaRcContent = rcContent;
|
||||||
|
|
|
@ -1285,9 +1285,7 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
hex-nvim = super.hex-nvim.overrideAttrs {
|
hex-nvim = super.hex-nvim.overrideAttrs {
|
||||||
postPatch = ''
|
runtimeDeps = [ xxd ];
|
||||||
substituteInPlace lua/hex.lua --replace xxd ${xxd}/bin/xxd
|
|
||||||
'';
|
|
||||||
nvimRequireCheck = "hex";
|
nvimRequireCheck = "hex";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue