neovim: add 'autoconfigure' setting (#356271)
certain plugins need a custom configuration (available in passthru.initLua) to work with nix. For instance unicode-vim needs to configure where to find the data: ``` vim.g.Unicode_data_directory="${self.unicode-vim}/autoload/unicode" ``` if true, the wrapper automatically appends those snippets when necessary first appearance of initLua in https://github.com/NixOS/nixpkgs/issues/352741 This will make testing those plugins easier.
This commit is contained in:
parent
b675ca747f
commit
d11140fa35
@ -80,7 +80,12 @@ let
|
||||
sha256 = "1ykcvyx82nhdq167kbnpgwkgjib8ii7c92y3427v986n2s5lsskc";
|
||||
};
|
||||
|
||||
# neovim-drv must be a wrapped neovim
|
||||
/* neovim-drv must be a wrapped neovim
|
||||
- exposes lua config in $luarcGeneric
|
||||
- exposes vim config in $vimrcGeneric
|
||||
|
||||
*/
|
||||
|
||||
runTest = neovim-drv: buildCommand:
|
||||
runCommandLocal "test-${neovim-drv.name}" ({
|
||||
nativeBuildInputs = [ ];
|
||||
@ -164,6 +169,13 @@ in
|
||||
${nvim_with_plug}/bin/nvim -V3log.txt -i NONE -c 'color base16-tomorrow-night' +quit! -e
|
||||
'';
|
||||
|
||||
nvim_with_autoconfigure = pkgs.neovim.overrideAttrs(oa: {
|
||||
plugins = [ vimPlugins.unicode-vim ];
|
||||
autoconfigure = true;
|
||||
# legacy wrapper sets it to false
|
||||
wrapRc = true;
|
||||
});
|
||||
|
||||
nvim_with_ftplugin = let
|
||||
# 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
|
||||
@ -324,6 +336,12 @@ in
|
||||
|
||||
inherit nvim-with-luasnip;
|
||||
|
||||
autoconfigure = runTest nvim_with_autoconfigure ''
|
||||
assertFileContains \
|
||||
"$luarc" \
|
||||
'${vimPlugins.unicode-vim.passthru.initLua}'
|
||||
'';
|
||||
|
||||
# check that bringing in one plugin with lua deps makes those deps visible from wrapper
|
||||
# for instance luasnip has a dependency on jsregexp
|
||||
can_require_transitive_deps =
|
||||
|
@ -20,6 +20,10 @@ let
|
||||
|
||||
wrapper = {
|
||||
extraName ? ""
|
||||
# certain plugins need a custom configuration (available in passthru.initLua)
|
||||
# to work with nix.
|
||||
# if true, the wrapper automatically appends those snippets when necessary
|
||||
, autoconfigure ? false
|
||||
# should contain all args but the binary. Can be either a string or list
|
||||
, wrapperArgs ? []
|
||||
, withPython2 ? false
|
||||
@ -87,11 +91,19 @@ let
|
||||
packpathDirs.myNeovimPackages = myVimPackage;
|
||||
finalPackdir = neovimUtils.packDir packpathDirs;
|
||||
|
||||
luaPluginRC = let
|
||||
op = acc: normalizedPlugin:
|
||||
acc ++ lib.optional (finalAttrs.autoconfigure && normalizedPlugin.plugin.passthru ? initLua) normalizedPlugin.plugin.passthru.initLua;
|
||||
in
|
||||
lib.foldl' op [] pluginsNormalized;
|
||||
|
||||
rcContent = ''
|
||||
${luaRcContent}
|
||||
'' + lib.optionalString (neovimRcContent' != null) ''
|
||||
vim.cmd.source "${writeText "init.vim" neovimRcContent'}"
|
||||
'';
|
||||
'' +
|
||||
lib.concatStringsSep "\n" luaPluginRC
|
||||
;
|
||||
|
||||
getDeps = attrname: map (plugin: plugin.${attrname} or (_: [ ]));
|
||||
|
||||
@ -155,7 +167,7 @@ let
|
||||
__structuredAttrs = true;
|
||||
dontUnpack = true;
|
||||
inherit viAlias vimAlias withNodeJs withPython3 withPerl withRuby;
|
||||
inherit wrapRc providerLuaRc packpathDirs;
|
||||
inherit autoconfigure wrapRc providerLuaRc packpathDirs;
|
||||
inherit python3Env rubyEnv;
|
||||
inherit wrapperArgs generatedWrapperArgs;
|
||||
luaRcContent = rcContent;
|
||||
|
Loading…
Reference in New Issue
Block a user