nvf/modules/default.nix

80 lines
2 KiB
Nix
Raw Normal View History

2023-02-10 17:39:31 +00:00
inputs: {
configuration,
pkgs,
lib ? pkgs.lib,
check ? true,
extraSpecialArgs ? {},
}: let
2023-08-01 14:28:06 +00:00
inherit (builtins) map filter isString toString getAttr;
inherit (pkgs) wrapNeovim vimPlugins;
inherit (pkgs.vimUtils) buildVimPlugin;
2023-02-06 18:58:23 +00:00
extendedLib = import ../lib/stdlib-extended.nix lib;
nvimModules = import ./modules.nix {
inherit check pkgs;
lib = extendedLib;
};
module = extendedLib.evalModules {
modules = [configuration] ++ nvimModules;
2023-08-01 14:28:06 +00:00
specialArgs = {modulesPath = toString ./.;} // extraSpecialArgs;
};
2023-11-06 09:33:38 +00:00
vimOptions = module.config.vim;
extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages;
buildPlug = {pname, ...} @ args:
assert lib.asserts.assertMsg (pname != "nvim-treesitter") "Use buildTreesitterPlug for building nvim-treesitter.";
buildVimPlugin (args
// {
version = "master";
src = getAttr pname inputs;
});
buildTreesitterPlug = grammars: vimPlugins.nvim-treesitter.withPlugins (_: grammars);
buildConfigPlugins = plugins:
map
(plug: (
if (isString plug)
then
(
if (plug == "nvim-treesitter")
then (buildTreesitterPlug vimOptions.treesitter.grammars)
else if (plug == "flutter-tools-patched")
then
(buildPlug {
pname = "flutter-tools";
patches = [../patches/flutter-tools.patch];
})
else (buildPlug {pname = plug;})
)
else plug
))
(filter
(f: f != null)
plugins);
2023-08-01 14:28:06 +00:00
neovim = wrapNeovim vimOptions.package {
inherit (vimOptions) viAlias;
inherit (vimOptions) vimAlias;
inherit extraLuaPackages;
configure = {
customRC = vimOptions.builtConfigRC;
packages.myVimPackage = {
start = buildConfigPlugins vimOptions.startPlugins;
opt = buildConfigPlugins vimOptions.optPlugins;
};
};
};
in {
inherit (module) options config;
inherit (module._module.args) pkgs;
inherit neovim;
}