2024-07-21 11:55:52 +03:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
helpers,
|
|
|
|
...
|
|
|
|
}:
|
2023-02-20 11:42:13 +01:00
|
|
|
let
|
2024-08-30 14:37:41 -05:00
|
|
|
inherit (lib) types mkOption;
|
|
|
|
|
2022-09-18 11:19:23 +01:00
|
|
|
pluginWithConfigType = types.submodule {
|
|
|
|
options = {
|
|
|
|
config = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
description = "vimscript for this plugin to be placed in init.vim";
|
|
|
|
default = "";
|
|
|
|
};
|
|
|
|
|
2024-08-30 14:37:41 -05:00
|
|
|
optional = lib.mkEnableOption "optional" // {
|
2023-02-20 11:42:13 +01:00
|
|
|
description = "Don't load by default (load with :packadd)";
|
|
|
|
};
|
2022-09-18 11:19:23 +01:00
|
|
|
|
|
|
|
plugin = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
description = "vim plugin";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-02-20 11:42:13 +01:00
|
|
|
in
|
|
|
|
{
|
2022-09-18 11:19:23 +01:00
|
|
|
options = {
|
2025-03-23 12:27:50 +01:00
|
|
|
env = mkOption {
|
|
|
|
type =
|
|
|
|
with types;
|
|
|
|
lazyAttrsOf (oneOf [
|
|
|
|
str
|
|
|
|
path
|
|
|
|
int
|
|
|
|
float
|
|
|
|
]);
|
|
|
|
description = "Environment variables to set in the neovim wrapper.";
|
|
|
|
default = { };
|
|
|
|
example = {
|
|
|
|
FOO = 1;
|
|
|
|
PI = 3.14;
|
|
|
|
BAR_PATH = "/home/me/.local/share/bar";
|
|
|
|
INFER_MODE = "local";
|
|
|
|
BAZ_MAX_COUNT = 1000;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-09-18 11:19:23 +01:00
|
|
|
extraPlugins = mkOption {
|
2024-12-17 18:19:29 +01:00
|
|
|
type = with types; listOf (nullOr (either package pluginWithConfigType));
|
2023-02-20 11:42:13 +01:00
|
|
|
default = [ ];
|
2022-09-18 11:19:23 +01:00
|
|
|
description = "List of vim plugins to install";
|
2024-12-17 18:19:29 +01:00
|
|
|
apply = builtins.filter (p: p != null);
|
2022-09-18 11:19:23 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
extraPackages = mkOption {
|
2024-04-23 16:41:27 +02:00
|
|
|
type = with types; listOf (nullOr package);
|
2023-02-20 11:42:13 +01:00
|
|
|
default = [ ];
|
2025-06-08 13:14:17 +01:00
|
|
|
description = "Extra packages to be made available to neovim, added to the start of `PATH`";
|
|
|
|
apply = builtins.filter (p: p != null);
|
|
|
|
};
|
|
|
|
|
|
|
|
extraPackagesAfter = mkOption {
|
|
|
|
type = with types; listOf (nullOr package);
|
|
|
|
default = [ ];
|
|
|
|
description = "Extra packages to be made available to neovim, added to the end of `PATH`";
|
2024-04-23 16:41:27 +02:00
|
|
|
apply = builtins.filter (p: p != null);
|
2022-09-18 11:19:23 +01:00
|
|
|
};
|
|
|
|
|
2024-01-06 14:59:00 -05:00
|
|
|
extraPython3Packages = mkOption {
|
2024-01-06 19:17:32 +01:00
|
|
|
type = with types; functionTo (listOf package);
|
|
|
|
default = p: [ ];
|
2024-08-30 14:37:41 -05:00
|
|
|
defaultText = lib.literalExpression "p: with p; [ ]";
|
2024-01-06 19:17:32 +01:00
|
|
|
description = "Python packages to add to the `PYTHONPATH` of neovim.";
|
|
|
|
example = lib.literalExpression ''
|
|
|
|
p: [ p.numpy ]
|
|
|
|
'';
|
2024-01-06 17:13:45 +01:00
|
|
|
};
|
|
|
|
|
2022-09-18 11:19:23 +01:00
|
|
|
extraConfigLua = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
2023-04-20 22:41:37 +02:00
|
|
|
description = "Extra contents for the file";
|
2022-09-18 11:19:23 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
extraConfigLuaPre = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
2023-04-20 22:41:37 +02:00
|
|
|
description = "Extra contents for the file before everything else";
|
2022-09-18 11:19:23 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
extraConfigLuaPost = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
2023-04-20 22:41:37 +02:00
|
|
|
description = "Extra contents for the file after everything else";
|
2022-09-18 11:19:23 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
extraConfigVim = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
2023-04-20 22:41:37 +02:00
|
|
|
description = "Extra contents for the file, in vimscript";
|
2022-09-18 11:19:23 +01:00
|
|
|
};
|
|
|
|
|
2023-04-20 22:41:37 +02:00
|
|
|
type = mkOption {
|
|
|
|
type = types.enum [
|
|
|
|
"vim"
|
|
|
|
"lua"
|
|
|
|
];
|
|
|
|
default = "lua";
|
2024-07-17 15:16:06 +01:00
|
|
|
description = ''
|
|
|
|
Whether the generated file is a vim or a lua file
|
|
|
|
|
|
|
|
Read-only outside of `files` submodules.
|
|
|
|
'';
|
|
|
|
readOnly = config.isTopLevel;
|
2022-10-17 15:08:17 +02:00
|
|
|
};
|
|
|
|
|
2023-04-20 22:41:37 +02:00
|
|
|
path = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "Path of the file relative to the config directory";
|
2022-10-17 15:08:17 +02:00
|
|
|
};
|
|
|
|
|
2023-04-20 22:41:37 +02:00
|
|
|
content = mkOption {
|
2022-10-17 15:08:17 +02:00
|
|
|
type = types.str;
|
2023-04-20 22:41:37 +02:00
|
|
|
description = "The content of the config file";
|
2022-09-18 11:19:23 +01:00
|
|
|
readOnly = true;
|
|
|
|
visible = false;
|
|
|
|
};
|
2023-03-18 22:44:34 +01:00
|
|
|
|
|
|
|
extraLuaPackages = mkOption {
|
|
|
|
type = types.functionTo (types.listOf types.package);
|
|
|
|
description = "Extra lua packages to include with neovim";
|
|
|
|
default = _: [ ];
|
|
|
|
};
|
2022-09-18 11:19:23 +01:00
|
|
|
};
|
|
|
|
|
2024-07-21 11:55:52 +03:00
|
|
|
config = {
|
|
|
|
content =
|
|
|
|
if config.type == "lua" then
|
|
|
|
# Lua
|
|
|
|
helpers.concatNonEmptyLines [
|
|
|
|
config.extraConfigLuaPre
|
|
|
|
(helpers.wrapVimscriptForLua config.extraConfigVim)
|
|
|
|
config.extraConfigLua
|
|
|
|
config.extraConfigLuaPost
|
|
|
|
]
|
|
|
|
else
|
|
|
|
# Vimscript
|
|
|
|
helpers.concatNonEmptyLines [
|
|
|
|
(helpers.wrapLuaForVimscript config.extraConfigLuaPre)
|
|
|
|
config.extraConfigVim
|
|
|
|
(helpers.wrapLuaForVimscript (
|
|
|
|
helpers.concatNonEmptyLines [
|
|
|
|
config.extraConfigLua
|
|
|
|
config.extraConfigLuaPost
|
|
|
|
]
|
|
|
|
))
|
|
|
|
];
|
|
|
|
};
|
2022-09-18 11:19:23 +01:00
|
|
|
}
|