2023-02-20 11:42:13 +01:00
|
|
|
{
|
|
|
|
lib,
|
2023-11-06 15:04:08 +01:00
|
|
|
config,
|
2023-02-20 11:42:13 +01:00
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib; let
|
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 = "";
|
|
|
|
};
|
|
|
|
|
2023-02-20 11:42:13 +01:00
|
|
|
optional =
|
|
|
|
mkEnableOption "optional"
|
|
|
|
// {
|
|
|
|
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 = {
|
|
|
|
extraPlugins = mkOption {
|
|
|
|
type = with types; listOf (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";
|
|
|
|
};
|
|
|
|
|
|
|
|
extraPackages = mkOption {
|
|
|
|
type = types.listOf types.package;
|
2023-02-20 11:42:13 +01:00
|
|
|
default = [];
|
2022-09-18 11:19:23 +01:00
|
|
|
description = "Extra packages to be made available to neovim";
|
|
|
|
};
|
|
|
|
|
|
|
|
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";
|
|
|
|
description = "Whether the generated file is a vim or a lua file";
|
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 = _: [];
|
|
|
|
};
|
2023-04-21 20:04:58 +02:00
|
|
|
|
|
|
|
extraFiles = mkOption {
|
|
|
|
type = types.attrsOf types.str;
|
|
|
|
description = "Extra files to add to the runtime path";
|
|
|
|
default = {};
|
|
|
|
};
|
2022-09-18 11:19:23 +01:00
|
|
|
};
|
|
|
|
|
2023-02-20 11:42:13 +01:00
|
|
|
config = let
|
2023-04-20 22:41:37 +02:00
|
|
|
contentLua = ''
|
|
|
|
${config.extraConfigLuaPre}
|
|
|
|
vim.cmd([[
|
|
|
|
${config.extraConfigVim}
|
|
|
|
]])
|
|
|
|
${config.extraConfigLua}
|
|
|
|
${config.extraConfigLuaPost}
|
|
|
|
'';
|
|
|
|
|
|
|
|
contentVim = ''
|
|
|
|
lua << EOF
|
2023-02-20 11:42:13 +01:00
|
|
|
${config.extraConfigLuaPre}
|
2023-04-20 22:41:37 +02:00
|
|
|
EOF
|
|
|
|
${config.extraConfigVim}
|
|
|
|
lua << EOF
|
2023-02-20 11:42:13 +01:00
|
|
|
${config.extraConfigLua}
|
|
|
|
${config.extraConfigLuaPost}
|
2023-04-20 22:41:37 +02:00
|
|
|
EOF
|
|
|
|
'';
|
2023-02-20 11:42:13 +01:00
|
|
|
in {
|
2023-04-20 22:41:37 +02:00
|
|
|
content =
|
|
|
|
if config.type == "lua"
|
|
|
|
then contentLua
|
|
|
|
else contentVim;
|
2023-02-20 11:42:13 +01:00
|
|
|
};
|
2022-09-18 11:19:23 +01:00
|
|
|
}
|