2023-02-10 18:39:31 +01:00
|
|
|
inputs: {
|
2023-02-01 20:11:37 +01:00
|
|
|
configuration,
|
|
|
|
pkgs,
|
2024-07-12 00:49:44 +02:00
|
|
|
lib,
|
2023-02-01 20:11:37 +01:00
|
|
|
check ? true,
|
|
|
|
extraSpecialArgs ? {},
|
2024-04-20 22:42:48 +02:00
|
|
|
extraModules ? [],
|
2023-02-01 20:11:37 +01:00
|
|
|
}: let
|
2024-07-13 17:05:21 +02:00
|
|
|
inherit (pkgs) vimPlugins;
|
2023-10-03 19:48:09 +02:00
|
|
|
inherit (pkgs.vimUtils) buildVimPlugin;
|
2024-07-13 17:05:21 +02:00
|
|
|
inherit (lib.strings) isString toString;
|
|
|
|
inherit (lib.lists) filter map concatLists;
|
|
|
|
inherit (lib.attrsets) recursiveUpdate getAttr;
|
2024-04-09 08:55:45 +02:00
|
|
|
inherit (lib.asserts) assertMsg;
|
2023-02-01 20:11:37 +01:00
|
|
|
|
2024-04-20 22:42:48 +02:00
|
|
|
# import modules.nix with `check`, `pkgs` and `lib` as arguments
|
|
|
|
# check can be disabled while calling this file is called
|
|
|
|
# to avoid checking in all modules
|
2023-02-01 20:11:37 +01:00
|
|
|
nvimModules = import ./modules.nix {
|
2024-07-12 00:49:44 +02:00
|
|
|
inherit pkgs check lib;
|
2023-02-01 20:11:37 +01:00
|
|
|
};
|
|
|
|
|
2024-04-20 22:42:48 +02:00
|
|
|
# evaluate the extended library with the modules
|
|
|
|
# optionally with any additional modules passed by the user
|
2024-07-12 00:49:44 +02:00
|
|
|
module = lib.evalModules {
|
2024-04-07 17:31:06 +02:00
|
|
|
specialArgs = recursiveUpdate {modulesPath = toString ./.;} extraSpecialArgs;
|
2024-04-20 22:42:48 +02:00
|
|
|
modules = concatLists [[configuration] nvimModules extraModules];
|
2023-02-01 20:11:37 +01:00
|
|
|
};
|
|
|
|
|
2024-04-20 22:42:48 +02:00
|
|
|
# alias to the internal configuration
|
2023-11-06 10:33:38 +01:00
|
|
|
vimOptions = module.config.vim;
|
|
|
|
|
2024-04-20 22:42:48 +02:00
|
|
|
# build a vim plugin with the given name and arguments
|
|
|
|
# if the plugin is nvim-treesitter, warn the user to use buildTreesitterPlug
|
|
|
|
# instead
|
2023-06-25 14:09:12 +02:00
|
|
|
buildPlug = {pname, ...} @ args:
|
2024-04-09 08:55:45 +02:00
|
|
|
assert assertMsg (pname != "nvim-treesitter") "Use buildTreesitterPlug for building nvim-treesitter.";
|
2023-10-03 19:48:09 +02:00
|
|
|
buildVimPlugin (args
|
2023-06-25 14:09:12 +02:00
|
|
|
// {
|
|
|
|
version = "master";
|
2024-04-09 08:55:45 +02:00
|
|
|
src = getAttr ("plugin-" + pname) inputs;
|
2023-06-25 14:09:12 +02:00
|
|
|
});
|
2023-02-01 20:11:37 +01:00
|
|
|
|
|
|
|
buildTreesitterPlug = grammars: vimPlugins.nvim-treesitter.withPlugins (_: grammars);
|
|
|
|
|
|
|
|
buildConfigPlugins = plugins:
|
|
|
|
map
|
|
|
|
(plug: (
|
|
|
|
if (isString plug)
|
|
|
|
then
|
|
|
|
(
|
|
|
|
if (plug == "nvim-treesitter")
|
|
|
|
then (buildTreesitterPlug vimOptions.treesitter.grammars)
|
2023-06-25 14:09:12 +02:00
|
|
|
else if (plug == "flutter-tools-patched")
|
|
|
|
then
|
|
|
|
(buildPlug {
|
|
|
|
pname = "flutter-tools";
|
|
|
|
patches = [../patches/flutter-tools.patch];
|
|
|
|
})
|
|
|
|
else (buildPlug {pname = plug;})
|
2023-02-01 20:11:37 +01:00
|
|
|
)
|
|
|
|
else plug
|
|
|
|
))
|
|
|
|
(filter
|
|
|
|
(f: f != null)
|
|
|
|
plugins);
|
|
|
|
|
2024-04-20 22:42:48 +02:00
|
|
|
# built (or "normalized") plugins that are modified
|
|
|
|
builtStartPlugins = buildConfigPlugins vimOptions.startPlugins;
|
|
|
|
builtOptPlugins = map (package: {
|
|
|
|
plugin = package;
|
2024-07-10 01:37:07 +02:00
|
|
|
optional = true;
|
2024-04-20 22:42:48 +02:00
|
|
|
}) (buildConfigPlugins vimOptions.optPlugins);
|
|
|
|
|
2024-04-21 02:21:48 +02:00
|
|
|
# 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
|
|
|
|
# here
|
2024-04-20 22:42:48 +02:00
|
|
|
extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages;
|
2024-04-21 01:23:07 +02:00
|
|
|
extraPython3Packages = ps: map (x: ps.${x}) vimOptions.python3Packages;
|
2024-04-20 22:42:48 +02:00
|
|
|
|
2024-07-13 17:05:21 +02:00
|
|
|
# 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;
|
2024-04-21 02:21:48 +02:00
|
|
|
|
2024-04-21 01:23:07 +02:00
|
|
|
inherit (vimOptions) viAlias vimAlias withRuby withNodeJs withPython3;
|
2024-07-13 17:05:21 +02:00
|
|
|
inherit extraLuaPackages extraPython3Packages;
|
2024-04-21 02:21:48 +02:00
|
|
|
};
|
2023-02-01 20:11:37 +01:00
|
|
|
in {
|
|
|
|
inherit (module) options config;
|
|
|
|
inherit (module._module.args) pkgs;
|
2024-04-20 22:42:48 +02:00
|
|
|
|
|
|
|
# expose wrapped neovim-package
|
|
|
|
neovim = neovim-wrapped;
|
2023-02-01 20:11:37 +01:00
|
|
|
}
|