From 2e766b185d2bb6fa38c0bd8fb980ba8fffeedb3a Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 29 Oct 2024 23:05:02 -0400 Subject: use custom wrapper (#70) * use custom wrapper * flake: use nix-filter on self * don't load remote plugins * use nvim-cmp and fidget from luarocks --- wrapper.nix | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 wrapper.nix (limited to 'wrapper.nix') diff --git a/wrapper.nix b/wrapper.nix new file mode 100644 index 0000000..1127e61 --- /dev/null +++ b/wrapper.nix @@ -0,0 +1,66 @@ +{ + lib, + emptyFile, + lua, + makeBinaryWrapper, + neovim-unwrapped, + neovimUtils, + runCommand, + writeText, +}: +{ + pname ? lib.removeSuffix "-unwrapped" neovim-unwrapped.pname, + version ? neovim-unwrapped.version, + name ? "${pname}-${version}", + makeWrapperArgs ? [ ], + luaPluginPackages ? _: [ ], + vimPluginPackages ? [ ], + runtimePrograms ? [ ], + luaRc ? emptyFile, + ... +}: + +let + luaEnv = lua.withPackages luaPluginPackages; + + normalizedPlugins = neovimUtils.normalizePlugins vimPluginPackages; + neovimPackage = neovimUtils.normalizedPluginsToVimPackage normalizedPlugins; + packDir = neovimUtils.packDir { inherit neovimPackage; }; + + vendorRc = writeText "vendor.vim" '' + lua package.path = "${luaEnv.luaPath}"; package.cpath = "${luaEnv.luaCpath}" + set packpath^=${packDir} | set runtimepath^=${packDir} + luafile ${luaRc} + ''; + + flags = [ + "-u" + (toString vendorRc) + ]; +in +runCommand name + { + __structuredAttrs = true; + + nativeBuildInputs = [ makeBinaryWrapper ]; + + makeWrapperArgs = makeWrapperArgs ++ [ + "--add-flags" + (lib.escapeShellArgs flags) + "--suffix" + "PATH" + ":" + (lib.makeBinPath runtimePrograms) + ]; + + passthru = { + inherit luaEnv; + }; + + meta = { + inherit (neovim-unwrapped.meta) description mainProgram; + }; + } + '' + makeWrapper ${lib.getExe neovim-unwrapped} $out/bin/nvim "''${makeWrapperArgs[@]}" + '' -- cgit v1.2.3