From 767eb62f48c0818e9f4392dc3eb61572cc8bd11d Mon Sep 17 00:00:00 2001 From: Stanislav Asunkin <1353637+stasjok@users.noreply.github.com> Date: Sun, 13 Oct 2024 09:54:05 +0300 Subject: [PATCH] modules/output: obtain plugin configs from wrapped neovim The official method for obtaining the generated initRc content is from wrapped neovim rather than from makeNeovimConfig helper. To use this approach: first wrap neovim with the generated config, then override it with our wrapperArgs. --- modules/top-level/output.nix | 18 ++++++++++-------- tests/test-sources/modules/output.nix | 4 ++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/modules/top-level/output.nix b/modules/top-level/output.nix index 360b91d8..030ef2d7 100644 --- a/modules/top-level/output.nix +++ b/modules/top-level/output.nix @@ -285,8 +285,10 @@ in } ); + wrappedNeovim' = pkgs.wrapNeovimUnstable package neovimConfig; + customRC = helpers.concatNonEmptyLines [ - (helpers.wrapVimscriptForLua neovimConfig.neovimRcContent) + (helpers.wrapVimscriptForLua wrappedNeovim'.initRc) config.content ]; @@ -330,13 +332,13 @@ in else config.package; - wrappedNeovim = pkgs.wrapNeovimUnstable package ( - neovimConfig - // { - wrapperArgs = lib.escapeShellArgs neovimConfig.wrapperArgs + " " + extraWrapperArgs; - wrapRc = false; - } - ); + wrappedNeovim = wrappedNeovim'.override (prev: { + wrapperArgs = + (if lib.isString prev.wrapperArgs then prev.wrapperArgs else lib.escapeShellArgs prev.wrapperArgs) + + " " + + extraWrapperArgs; + wrapRc = false; + }); in { build = { diff --git a/tests/test-sources/modules/output.nix b/tests/test-sources/modules/output.nix index b3d4f85f..aa021685 100644 --- a/tests/test-sources/modules/output.nix +++ b/tests/test-sources/modules/output.nix @@ -48,7 +48,7 @@ extraPlugins = [ { - config = "let g:var = 'neovimRcContent5'"; + config = "let g:var = 'wrappedNeovim.initRc5'"; # Test that final init.lua contains all config sections plugin = pkgs.runCommandLocal "init-lua-content-test" { } '' @@ -63,7 +63,7 @@ test_content extraConfigLua2 extraConfigLua test_content extraConfigLuaPost3 extraConfigLuaPost test_content extraConfigVim4 extraConfigVim4 - test_content neovimRcContent5 neovimRcContent + test_content wrappedNeovim.initRc5 wrappedNeovim.initRc touch $out '';