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>
This commit is contained in:
raf 2024-07-13 15:05:21 +00:00 committed by GitHub
parent 32d231395f
commit 5fab82ba91
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 40 additions and 30 deletions

View file

@ -88,6 +88,26 @@
"type": "github" "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": { "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

@ -80,6 +80,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) 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;
# import modules.nix with `check`, `pkgs` and `lib` as arguments # import modules.nix with `check`, `pkgs` and `lib` as arguments
@ -74,10 +72,6 @@ inputs: {
optional = true; optional = true;
}) (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
@ -85,29 +79,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"];
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 (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;