modules: switch to gerg's neovim-wrapper

This commit is contained in:
raf 2024-07-09 00:24:40 +03:00
commit 53971939a5
Signed by: NotAShelf
GPG key ID: AF26552424E53993
3 changed files with 40 additions and 30 deletions

21
flake.lock generated
View file

@ -88,6 +88,26 @@
"type": "github" "type": "github"
} }
}, },
"neovim-wrapper": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1720472688,
"narHash": "sha256-IQqFxe+LwXCjLSosxz3TP9xNRf1VCuWbI4JuBTC6ys4=",
"owner": "Gerg-L",
"repo": "neovim-wrapper",
"rev": "25d77eb68da40577727d1f71a569a9ff5c15cc26",
"type": "github"
},
"original": {
"owner": "Gerg-L",
"repo": "neovim-wrapper",
"type": "github"
}
},
"nil": { "nil": {
"inputs": { "inputs": {
"flake-utils": [ "flake-utils": [
@ -1781,6 +1801,7 @@
"inputs": { "inputs": {
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"neovim-wrapper": "neovim-wrapper",
"nil": "nil", "nil": "nil",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nmd": "nmd", "nmd": "nmd",

View file

@ -77,6 +77,12 @@
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
systems.url = "github:nix-systems/default"; 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 # For generating documentation website
nmd = { nmd = {
url = "sourcehut:~rycee/nmd"; url = "sourcehut:~rycee/nmd";

View file

@ -6,13 +6,11 @@ inputs: {
extraSpecialArgs ? {}, extraSpecialArgs ? {},
extraModules ? [], extraModules ? [],
}: let }: let
inherit (builtins) map filter isString toString getAttr; inherit (pkgs) vimPlugins;
inherit (pkgs) wrapNeovimUnstable vimPlugins;
inherit (pkgs.vimUtils) buildVimPlugin; inherit (pkgs.vimUtils) buildVimPlugin;
inherit (pkgs.neovimUtils) makeNeovimConfig; inherit (lib.strings) makeBinPath isString toString;
inherit (lib.strings) makeBinPath escapeShellArgs concatStringsSep; inherit (lib.lists) filter map concatLists;
inherit (lib.lists) concatLists optional; inherit (lib.attrsets) recursiveUpdate getAttr;
inherit (lib.attrsets) recursiveUpdate;
inherit (lib.asserts) assertMsg; inherit (lib.asserts) assertMsg;
# call the extedended library with `lib` and `inputs` as arguments # call the extedended library with `lib` and `inputs` as arguments
@ -81,10 +79,6 @@ inputs: {
optional = false; optional = false;
}) (buildConfigPlugins vimOptions.optPlugins); }) (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 # additional Lua and Python3 packages, mapped to their respective functions
# to conform to the format makeNeovimConfig expects. end user should # to conform to the format makeNeovimConfig expects. end user should
# only ever need to pass a list of packages, which are modified # only ever need to pass a list of packages, which are modified
@ -92,29 +86,18 @@ inputs: {
extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages; extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages;
extraPython3Packages = ps: map (x: ps.${x}) vimOptions.python3Packages; extraPython3Packages = ps: map (x: ps.${x}) vimOptions.python3Packages;
extraWrapperArgs = # Wrap the user's desired (unwrapped) Neovim package with arguments that'll be used to
concatStringsSep " " (optional (vimOptions.extraPackages != []) ''--prefix PATH : "${makeBinPath vimOptions.extraPackages}"''); # 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"];
extraLuaFiles = [(pkgs.writeText "nvf-init.vim" 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 (vimOptions) viAlias vimAlias withRuby withNodeJs withPython3;
inherit plugins extraLuaPackages extraPython3Packages; inherit extraLuaPackages extraPython3Packages;
customRC = vimOptions.builtConfigRC;
}; };
neovim-wrapped = wrapNeovimUnstable vimOptions.package (recursiveUpdate neovimConfigured {
wrapperArgs = escapeShellArgs neovimConfigured.wrapperArgs + " " + extraWrapperArgs;
});
in { in {
inherit (module) options config; inherit (module) options config;
inherit (module._module.args) pkgs; inherit (module._module.args) pkgs;