mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2025-01-09 16:39:51 +01:00
Compare commits
4 commits
09307ec4df
...
25dc887a8e
Author | SHA1 | Date | |
---|---|---|---|
25dc887a8e | |||
8ca0760b01 | |||
e982955540 | |||
0388898648 |
5 changed files with 77 additions and 49 deletions
|
@ -7,9 +7,11 @@ inputs: let
|
||||||
lib ? pkgs.lib,
|
lib ? pkgs.lib,
|
||||||
check ? true,
|
check ? true,
|
||||||
extraSpecialArgs ? {},
|
extraSpecialArgs ? {},
|
||||||
|
extraModules ? [],
|
||||||
|
...
|
||||||
}:
|
}:
|
||||||
modulesWithInputs {
|
modulesWithInputs {
|
||||||
inherit pkgs lib check extraSpecialArgs;
|
inherit pkgs lib check extraSpecialArgs extraModules;
|
||||||
configuration.imports = modules;
|
configuration.imports = modules;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@ packages: inputs: {
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib) maintainers;
|
inherit (lib) maintainers;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf;
|
||||||
inherit (lib.lists) optionals;
|
inherit (lib.lists) optional;
|
||||||
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
||||||
inherit (lib.types) attrsOf anything bool;
|
inherit (lib.types) attrsOf anything bool;
|
||||||
|
|
||||||
|
@ -74,16 +74,14 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable mkMerge [
|
config = mkIf cfg.enable {
|
||||||
{
|
programs.neovim-flake.finalPackage = neovimConfigured.neovim;
|
||||||
programs.neovim-flake.finalPackage = neovimConfigured.neovim;
|
|
||||||
|
|
||||||
home = {
|
home = {
|
||||||
sessionVariables.EDITOR = mkIf cfg.defaultEditor (lib.mkOverride 900 "nvim");
|
sessionVariables = mkIf cfg.defaultEditor {EDITOR = "nvim";};
|
||||||
packages =
|
packages =
|
||||||
[cfg.finalPackage]
|
[cfg.finalPackage]
|
||||||
++ optionals cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages;
|
++ optional cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages;
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@ packages: inputs: {
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib) maintainers;
|
inherit (lib) maintainers;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkOverride;
|
||||||
inherit (lib.lists) optionals;
|
inherit (lib.lists) optional;
|
||||||
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
||||||
inherit (lib.types) attrsOf anything bool;
|
inherit (lib.types) attrsOf anything bool;
|
||||||
|
|
||||||
|
@ -74,16 +74,14 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable mkMerge [
|
config = mkIf cfg.enable {
|
||||||
{
|
programs.neovim-flake.finalPackage = neovimConfigured.neovim;
|
||||||
programs.neovim-flake.finalPackage = neovimConfigured.neovim;
|
|
||||||
|
|
||||||
environment = {
|
environment = {
|
||||||
variables.EDITOR = mkIf cfg.defaultEditor (lib.mkOverride 900 "nvim");
|
variables.EDITOR = mkIf cfg.defaultEditor (mkOverride 900 "nvim");
|
||||||
systemPackages =
|
systemPackages =
|
||||||
[cfg.finalPackage]
|
[cfg.finalPackage]
|
||||||
++ optionals cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages;
|
++ optional cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages;
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,30 +4,43 @@ inputs: {
|
||||||
lib ? pkgs.lib,
|
lib ? pkgs.lib,
|
||||||
check ? true,
|
check ? true,
|
||||||
extraSpecialArgs ? {},
|
extraSpecialArgs ? {},
|
||||||
|
extraModules ? [],
|
||||||
}: let
|
}: let
|
||||||
inherit (builtins) map filter isString toString getAttr;
|
inherit (builtins) map filter isString toString getAttr;
|
||||||
inherit (pkgs) wrapNeovimUnstable vimPlugins;
|
inherit (pkgs) wrapNeovimUnstable vimPlugins;
|
||||||
inherit (pkgs.vimUtils) buildVimPlugin;
|
inherit (pkgs.vimUtils) buildVimPlugin;
|
||||||
inherit (pkgs.neovimUtils) makeNeovimConfig;
|
inherit (pkgs.neovimUtils) makeNeovimConfig;
|
||||||
|
inherit (lib.lists) concatLists;
|
||||||
inherit (lib.attrsets) recursiveUpdate;
|
inherit (lib.attrsets) recursiveUpdate;
|
||||||
inherit (lib.asserts) assertMsg;
|
inherit (lib.asserts) assertMsg;
|
||||||
|
|
||||||
|
# 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
|
||||||
extendedLib = import ../lib/stdlib-extended.nix lib inputs;
|
extendedLib = import ../lib/stdlib-extended.nix lib inputs;
|
||||||
|
|
||||||
|
# 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
|
||||||
nvimModules = import ./modules.nix {
|
nvimModules = import ./modules.nix {
|
||||||
inherit check pkgs;
|
inherit check pkgs;
|
||||||
lib = extendedLib;
|
lib = extendedLib;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# evaluate the extended library with the modules
|
||||||
|
# optionally with any additional modules passed by the user
|
||||||
module = extendedLib.evalModules {
|
module = extendedLib.evalModules {
|
||||||
modules = [configuration] ++ nvimModules;
|
|
||||||
specialArgs = recursiveUpdate {modulesPath = toString ./.;} extraSpecialArgs;
|
specialArgs = recursiveUpdate {modulesPath = toString ./.;} extraSpecialArgs;
|
||||||
|
modules = concatLists [[configuration] nvimModules extraModules];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# alias to the internal configuration
|
||||||
vimOptions = module.config.vim;
|
vimOptions = module.config.vim;
|
||||||
|
|
||||||
extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages;
|
# build a vim plugin with the given name and arguments
|
||||||
|
# if the plugin is nvim-treesitter, warn the user to use buildTreesitterPlug
|
||||||
|
# instead
|
||||||
buildPlug = {pname, ...} @ args:
|
buildPlug = {pname, ...} @ args:
|
||||||
assert assertMsg (pname != "nvim-treesitter") "Use buildTreesitterPlug for building nvim-treesitter.";
|
assert assertMsg (pname != "nvim-treesitter") "Use buildTreesitterPlug for building nvim-treesitter.";
|
||||||
buildVimPlugin (args
|
buildVimPlugin (args
|
||||||
|
@ -60,24 +73,36 @@ inputs: {
|
||||||
(f: f != null)
|
(f: f != null)
|
||||||
plugins);
|
plugins);
|
||||||
|
|
||||||
plugins =
|
# built (or "normalized") plugins that are modified
|
||||||
(buildConfigPlugins vimOptions.startPlugins)
|
builtStartPlugins = buildConfigPlugins vimOptions.startPlugins;
|
||||||
++ (map (package: {
|
builtOptPlugins = map (package: {
|
||||||
plugin = package;
|
plugin = package;
|
||||||
optional = false;
|
optional = false;
|
||||||
})
|
}) (buildConfigPlugins vimOptions.optPlugins);
|
||||||
(buildConfigPlugins
|
|
||||||
vimOptions.optPlugins));
|
|
||||||
|
|
||||||
neovim = wrapNeovimUnstable vimOptions.package (makeNeovimConfig {
|
plugins = builtStartPlugins ++ builtOptPlugins;
|
||||||
inherit (vimOptions) viAlias;
|
|
||||||
inherit (vimOptions) vimAlias;
|
extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages;
|
||||||
inherit extraLuaPackages;
|
|
||||||
inherit plugins;
|
# 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;
|
||||||
customRC = vimOptions.builtConfigRC;
|
customRC = vimOptions.builtConfigRC;
|
||||||
});
|
});
|
||||||
in {
|
in {
|
||||||
inherit (module) options config;
|
inherit (module) options config;
|
||||||
inherit (module._module.args) pkgs;
|
inherit (module._module.args) pkgs;
|
||||||
inherit neovim;
|
|
||||||
|
# expose wrapped neovim-package
|
||||||
|
neovim = neovim-wrapped;
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,7 +229,9 @@ in {
|
||||||
if [vim.enableLuaLoader](#opt-vim.enableLuaLoader) is set to true.
|
if [vim.enableLuaLoader](#opt-vim.enableLuaLoader) is set to true.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
description = literalMD ''
|
example = literalExpression ''"$${builtins.readFile ./my-lua-config-pre.lua}"'';
|
||||||
|
|
||||||
|
description = ''
|
||||||
Verbatim lua code that will be inserted **before**
|
Verbatim lua code that will be inserted **before**
|
||||||
the result of `luaConfigRc` DAG has been resolved.
|
the result of `luaConfigRc` DAG has been resolved.
|
||||||
|
|
||||||
|
@ -238,9 +240,11 @@ in {
|
||||||
of lua configs after the DAG result.
|
of lua configs after the DAG result.
|
||||||
|
|
||||||
::: {.warning}
|
::: {.warning}
|
||||||
You do not want to override this option. It is used
|
You do not want to override this option with mkForce
|
||||||
internally to set certain options as early as possible
|
It is used internally to set certain options as early
|
||||||
and should be avoided unless you know what you're doing.
|
as possible and should be avoided unless you know what
|
||||||
|
you're doing. Passing a string to this option will
|
||||||
|
merge it with the default contents.
|
||||||
:::
|
:::
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
@ -269,8 +273,9 @@ in {
|
||||||
luaConfigPost = mkOption {
|
luaConfigPost = mkOption {
|
||||||
type = str;
|
type = str;
|
||||||
default = "";
|
default = "";
|
||||||
|
example = literalExpression ''"$${builtins.readFile ./my-lua-config-post.lua}"'';
|
||||||
description = ''
|
description = ''
|
||||||
Verbatim lua code that will be inserted after
|
Verbatim lua code that will be inserted **after**
|
||||||
the result of the `luaConfigRc` DAG has been resolved
|
the result of the `luaConfigRc` DAG has been resolved
|
||||||
|
|
||||||
This option **does not** take a DAG set, but a string
|
This option **does not** take a DAG set, but a string
|
||||||
|
|
Loading…
Reference in a new issue