Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion pkgs/applications/editors/neovim/tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do this on next update ty

*/

runTest = neovim-drv: buildCommand:
runCommandLocal "test-${neovim-drv.name}" ({
nativeBuildInputs = [ ];
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 =
Expand Down
16 changes: 14 additions & 2 deletions pkgs/applications/editors/neovim/wrapper.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: foldl' will reverse the order (correct me if mistaken). Do we care about this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think so, the accumulator comes first.
applying

diff --git a/pkgs/applications/editors/neovim/tests/default.nix b/pkgs/applications/editors/neovim/tests/default.nix
index fb89d47aceb0..48b00d42f272 100644
--- a/pkgs/applications/editors/neovim/tests/default.nix
+++ b/pkgs/applications/editors/neovim/tests/default.nix
@@ -170,7 +170,10 @@ in
   '';
 
   nvim_with_autoconfigure = pkgs.neovim.overrideAttrs(oa: {
-    plugins = [ vimPlugins.unicode-vim ];
+    plugins = [
+      vimPlugins.unicode-vim
+      vimPlugins.fzf-hoogle-vim
+    ];
     autoconfigure = true;
     # legacy wrapper sets it to false
     wrapRc = true;

generated

vim.cmd.source "/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-init.vim"
vim.g.Unicode_data_directory="/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-vimplugin-unicode.vim-2024-07-23/autoload/unicode"
vim.g.hoogle_fzf_cache_file = vim.fn.stdpath('cache')..'/hoogle_cache.json


rcContent = ''
${luaRcContent}
'' + lib.optionalString (neovimRcContent' != null) ''
vim.cmd.source "${writeText "init.vim" neovimRcContent'}"
'';
'' +
lib.concatStringsSep "\n" luaPluginRC
;

getDeps = attrname: map (plugin: plugin.${attrname} or (_: [ ]));

Expand Down Expand Up @@ -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;
Expand Down