2023-02-10 17:39:31 +00:00
|
|
|
inputs: {
|
2023-02-01 19:11:37 +00:00
|
|
|
configuration,
|
|
|
|
pkgs,
|
|
|
|
lib ? pkgs.lib,
|
|
|
|
check ? true,
|
|
|
|
extraSpecialArgs ? {},
|
2024-04-20 20:42:48 +00:00
|
|
|
extraModules ? [],
|
2023-02-01 19:11:37 +00:00
|
|
|
}: let
|
2023-08-01 14:28:06 +00:00
|
|
|
inherit (builtins) map filter isString toString getAttr;
|
2024-02-29 20:15:47 +00:00
|
|
|
inherit (pkgs) wrapNeovimUnstable vimPlugins;
|
2023-10-03 17:48:09 +00:00
|
|
|
inherit (pkgs.vimUtils) buildVimPlugin;
|
2024-02-29 20:15:47 +00:00
|
|
|
inherit (pkgs.neovimUtils) makeNeovimConfig;
|
2024-04-20 20:42:48 +00:00
|
|
|
inherit (lib.lists) concatLists;
|
2024-04-07 15:31:06 +00:00
|
|
|
inherit (lib.attrsets) recursiveUpdate;
|
2024-04-09 06:55:45 +00:00
|
|
|
inherit (lib.asserts) assertMsg;
|
2023-02-01 19:11:37 +00:00
|
|
|
|
2024-04-20 20:42:48 +00:00
|
|
|
# call the extedended library with `lib` and `inputs` as arguments
|
|
|
|
# lib is used to provide the standard library functions to the extended library
|
|
|
|
# but it can be overridden while this file is being called
|
|
|
|
# inputs is used to pass inputs to the plugin autodiscovery function
|
2024-04-08 00:28:49 +00:00
|
|
|
extendedLib = import ../lib/stdlib-extended.nix lib inputs;
|
2023-02-01 19:11:37 +00:00
|
|
|
|
2024-04-20 20:42:48 +00: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 19:11:37 +00:00
|
|
|
nvimModules = import ./modules.nix {
|
|
|
|
inherit check pkgs;
|
|
|
|
lib = extendedLib;
|
|
|
|
};
|
|
|
|
|
2024-04-20 20:42:48 +00:00
|
|
|
# evaluate the extended library with the modules
|
|
|
|
# optionally with any additional modules passed by the user
|
2023-02-01 19:11:37 +00:00
|
|
|
module = extendedLib.evalModules {
|
2024-04-07 15:31:06 +00:00
|
|
|
specialArgs = recursiveUpdate {modulesPath = toString ./.;} extraSpecialArgs;
|
2024-04-20 20:42:48 +00:00
|
|
|
modules = concatLists [[configuration] nvimModules extraModules];
|
2023-02-01 19:11:37 +00:00
|
|
|
};
|
|
|
|
|
2024-04-20 20:42:48 +00:00
|
|
|
# alias to the internal configuration
|
2023-11-06 09:33:38 +00:00
|
|
|
vimOptions = module.config.vim;
|
|
|
|
|
2024-04-20 20:42:48 +00: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 12:09:12 +00:00
|
|
|
buildPlug = {pname, ...} @ args:
|
2024-04-09 06:55:45 +00:00
|
|
|
assert assertMsg (pname != "nvim-treesitter") "Use buildTreesitterPlug for building nvim-treesitter.";
|
2023-10-03 17:48:09 +00:00
|
|
|
buildVimPlugin (args
|
2023-06-25 12:09:12 +00:00
|
|
|
// {
|
|
|
|
version = "master";
|
2024-04-09 06:55:45 +00:00
|
|
|
src = getAttr ("plugin-" + pname) inputs;
|
2023-06-25 12:09:12 +00:00
|
|
|
});
|
2023-02-01 19:11:37 +00: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 12:09:12 +00:00
|
|
|
else if (plug == "flutter-tools-patched")
|
|
|
|
then
|
|
|
|
(buildPlug {
|
|
|
|
pname = "flutter-tools";
|
|
|
|
patches = [../patches/flutter-tools.patch];
|
|
|
|
})
|
|
|
|
else (buildPlug {pname = plug;})
|
2023-02-01 19:11:37 +00:00
|
|
|
)
|
|
|
|
else plug
|
|
|
|
))
|
|
|
|
(filter
|
|
|
|
(f: f != null)
|
|
|
|
plugins);
|
|
|
|
|
2024-04-20 20:42:48 +00:00
|
|
|
# built (or "normalized") plugins that are modified
|
|
|
|
builtStartPlugins = buildConfigPlugins vimOptions.startPlugins;
|
|
|
|
builtOptPlugins = map (package: {
|
|
|
|
plugin = package;
|
|
|
|
optional = false;
|
|
|
|
}) (buildConfigPlugins vimOptions.optPlugins);
|
|
|
|
|
|
|
|
plugins = builtStartPlugins ++ builtOptPlugins;
|
2024-02-29 20:15:47 +00:00
|
|
|
|
2024-04-20 20:42:48 +00:00
|
|
|
extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages;
|
|
|
|
|
|
|
|
# wrap user's desired neovim package using the neovim wrapper from nixpkgs
|
|
|
|
# the wrapper takes the following arguments:
|
|
|
|
# - withPython (bool)
|
|
|
|
# - extraPython3Packages (lambda)
|
|
|
|
# - withNodeJs (bool)
|
|
|
|
# - withRuby (bool)
|
|
|
|
# - extraLuaPackages (lambda)
|
|
|
|
# - plugins (list)
|
|
|
|
# - customRC (string)
|
|
|
|
# and returns the wrapped package
|
|
|
|
neovim-wrapped = wrapNeovimUnstable vimOptions.package (makeNeovimConfig {
|
|
|
|
inherit (vimOptions) viAlias vimAlias;
|
|
|
|
inherit plugins extraLuaPackages;
|
2024-02-29 20:15:47 +00:00
|
|
|
customRC = vimOptions.builtConfigRC;
|
|
|
|
});
|
2023-02-01 19:11:37 +00:00
|
|
|
in {
|
|
|
|
inherit (module) options config;
|
|
|
|
inherit (module._module.args) pkgs;
|
2024-04-20 20:42:48 +00:00
|
|
|
|
|
|
|
# expose wrapped neovim-package
|
|
|
|
neovim = neovim-wrapped;
|
2023-02-01 19:11:37 +00:00
|
|
|
}
|