From 5fab82ba91f6d87e364d1aafff7131f675c8a8da Mon Sep 17 00:00:00 2001 From: raf Date: Sat, 13 Jul 2024 15:05:21 +0000 Subject: [PATCH] modules: switch to gerg's neovim-wrapper (#325) * modules: switch to gerg's neovim-wrapper * Use initViml instead of writeText (#330) --------- Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com> --- flake.lock | 21 +++++++++++++++++++++ flake.nix | 6 ++++++ modules/default.nix | 43 +++++++++++++------------------------------ 3 files changed, 40 insertions(+), 30 deletions(-) diff --git a/flake.lock b/flake.lock index 2c46aec6..83f39f9a 100644 --- a/flake.lock +++ b/flake.lock @@ -88,6 +88,26 @@ "type": "github" } }, + "neovim-wrapper": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1720539383, + "narHash": "sha256-HF4+pQJwgw62lLpWo5TiXFb8ui0FpZcb2TkSh9qXju8=", + "owner": "Gerg-L", + "repo": "neovim-wrapper", + "rev": "a2b26accc1c414bc0ef0132ab167e2973dc26e68", + "type": "github" + }, + "original": { + "owner": "Gerg-L", + "repo": "neovim-wrapper", + "type": "github" + } + }, "nil": { "inputs": { "flake-utils": [ @@ -1781,6 +1801,7 @@ "inputs": { "flake-parts": "flake-parts", "flake-utils": "flake-utils", + "neovim-wrapper": "neovim-wrapper", "nil": "nil", "nixpkgs": "nixpkgs", "nmd": "nmd", diff --git a/flake.nix b/flake.nix index ea66b53f..325e93c1 100644 --- a/flake.nix +++ b/flake.nix @@ -80,6 +80,12 @@ flake-utils.url = "github:numtide/flake-utils"; systems.url = "github:nix-systems/default"; + # Alternate neovim-wrapper + neovim-wrapper = { + url = "github:Gerg-L/neovim-wrapper"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + # For generating documentation website nmd = { url = "sourcehut:~rycee/nmd"; diff --git a/modules/default.nix b/modules/default.nix index 941c18fa..529c8059 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -6,13 +6,11 @@ inputs: { extraSpecialArgs ? {}, extraModules ? [], }: let - inherit (builtins) map filter isString toString getAttr; - inherit (pkgs) wrapNeovimUnstable vimPlugins; + inherit (pkgs) vimPlugins; inherit (pkgs.vimUtils) buildVimPlugin; - inherit (pkgs.neovimUtils) makeNeovimConfig; - inherit (lib.strings) makeBinPath escapeShellArgs concatStringsSep; - inherit (lib.lists) concatLists optional; - inherit (lib.attrsets) recursiveUpdate; + inherit (lib.strings) isString toString; + inherit (lib.lists) filter map concatLists; + inherit (lib.attrsets) recursiveUpdate getAttr; inherit (lib.asserts) assertMsg; # import modules.nix with `check`, `pkgs` and `lib` as arguments @@ -74,10 +72,6 @@ inputs: { optional = true; }) (buildConfigPlugins vimOptions.optPlugins); - # combine built start and optional plugins - # into a single list - plugins = builtStartPlugins ++ builtOptPlugins; - # additional Lua and Python3 packages, mapped to their respective functions # to conform to the format makeNeovimConfig expects. end user should # only ever need to pass a list of packages, which are modified @@ -85,29 +79,18 @@ inputs: { extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages; extraPython3Packages = ps: map (x: ps.${x}) vimOptions.python3Packages; - extraWrapperArgs = - concatStringsSep " " (optional (vimOptions.extraPackages != []) ''--prefix PATH : "${makeBinPath vimOptions.extraPackages}"''); + # Wrap the user's desired (unwrapped) Neovim package with arguments that'll be used to + # generate a wrapped Neovim package. + neovim-wrapped = inputs.neovim-wrapper.legacyPackages.${pkgs.stdenv.system}.neovimWrapper { + neovim = vimOptions.package; + plugins = concatLists [builtStartPlugins builtOptPlugins]; + wrapperArgs = ["--set" "NVIM_APPNAME" "nvf"]; + initViml = vimOptions.builtConfigRC; + extraBinPath = vimOptions.extraPackages; - # wrap user's desired neovim package with the desired neovim configuration - # using wrapNeovimUnstable and makeNeovimConfig from nixpkgs. - # the makeNeovimConfig function takes the following arguments: - # - withPython (bool) - # - extraPython3Packages (lambda) - # - withNodeJs (bool) - # - withRuby (bool) - # - extraLuaPackages (lambda) - # - plugins (list) - # - customRC (string) - # and returns the wrapped package - neovimConfigured = makeNeovimConfig { inherit (vimOptions) viAlias vimAlias withRuby withNodeJs withPython3; - inherit plugins extraLuaPackages extraPython3Packages; - customRC = vimOptions.builtConfigRC; + inherit extraLuaPackages extraPython3Packages; }; - - neovim-wrapped = wrapNeovimUnstable vimOptions.package (recursiveUpdate neovimConfigured { - wrapperArgs = escapeShellArgs neovimConfigured.wrapperArgs + " " + extraWrapperArgs; - }); in { inherit (module) options config; inherit (module._module.args) pkgs;